Commit Graph

72 Commits

Author SHA1 Message Date
Erik Verbruggen e1bbbb6cf9 Fix isel for eval and a whole bunch of other warnings.
A factory is now passed along to do the codegen for eval().

Change-Id: If15b1f28c9c0a8f8b6d18b56d6e7bc5d942927e5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-19 14:02:58 +01:00
Erik Verbruggen b072fd9317 Added isNaN and isFinite to the global context.
Change-Id: Ia85d27a6ac82fd5dbf6b0f706747afa6418626b1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-19 13:57:51 +01:00
Lars Knoll a267688480 Better handling of contexts and environments
Make the ExecutionContext standard compliant.
Move most of it's members into a new
DeclarativeEnvironment data structure that
contains locals and arguments.

Change-Id: I094f559168810dbd3717d677fe28750076015976
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-19 10:33:35 +01:00
Lars Knoll 65724ce3e7 Move the engine and context classes into their own files
Change-Id: Ie20138990908a921ca3d7475618275ed82d9cb5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-19 10:29:07 +01:00
Lars Knoll d7416a80fa Rename Context to ExecutionContext
This is so it'll map to the name used in the
ECMAScript spec once the other refactorings
are in.

Change-Id: I8dcc7ad43b457ce50e7123c57bc4c770bcda8d11
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-19 10:28:56 +01:00
Lars Knoll d6553a206b Create a proper function object for eval
Still doesn't work correctly, as we can't modify
the global context there.

Change-Id: Ifd0ab217c3cf2d0c1b86f09907b440ea31c29ac8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-18 13:21:21 +01:00
Erik Verbruggen 72b478b8a2 Added all missing error objects.
Change-Id: I806184c5593af44d79b21afb1e3235ec9afa1e2a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-15 13:45:42 +01:00
Lars Knoll bd63199bba Cleanup Context initialization
Make the initialization for call() compliant
with the standard, and add a strict mode boolean.

Change-Id: I8617af8dbfde47d8b2a8a0a7ce0ab491031ba4ba
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-15 13:43:53 +01:00
Lars Knoll 4810e095b7 Store the activation object as a pointer, not as a Value.
The activation object inside the context is always an object,
or null. This avoids some needless conversions to and from
Value's.

Change-Id: Ibbd88c83fa073a4ed3cf03742129357dd9567cec
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-15 13:40:55 +01:00
Erik Verbruggen 68b099b8f8 Add missing message property to the ErrorObject.
Change-Id: Ice16360f98d1d66162440d972c6bfbc416884474
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-11-14 14:19:05 +01:00
Lars Knoll bc42b47a11 Better argument ordering.
Change-Id: I1d47ce7bd2cf27bc43a0e9afbfb2914296c9d704
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-11-12 09:18:12 +01:00
Lars Knoll c5b258c21d Clean up inplace binary operations for subscripts.
Remove a lot of duplicated code, and make it a lot
easier to implement JS compliant semantics.

Change-Id: Ic5ecb58d34a5df8fe05e86c5f906d70c50c51b54
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-11-12 09:17:23 +01:00
Lars Knoll 0c1424362f Improve handling of binops on LHS expressions
Add a generic method to handle binops such as +=
to Object and use it. We can probably remove
most of the __qmljs_inplace_xxx methods later
on and call one generic method instead.

Change-Id: If7cbd2e3012ad381e29b9eec2059e17f02a0a38a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-11-11 21:24:43 +01:00
Lars Knoll d5fe0946bd Cleanup call and construct semantics
Implement proper call() and construct()
methods in FunctionObject, and remove
some duplicated initialization code.

Change-Id: I5c86f9f2cf6e4b65d23d000149db2b79c35538c4
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-11-11 21:24:38 +01:00
Lars Knoll 6f931118d6 Initial implementation of the Error prototype and constructor
Change-Id: Iffd1a01b75bc923c0cd8c0b786558be20a52ab2c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-11-01 15:58:07 +01:00
Lars Knoll 9fff7d8869 Add undefined, NaN and Infinity to the global object
Change-Id: Ic5047c231ab54ccc04043bf95418c0f6511b10bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-31 17:00:48 +01:00
Lars Knoll 477ea45b0b Set property attributes more correctly
Also now check for enumerable in for/in statements.

Change-Id: I03a9968fc3d7f8f5e4eaf26591040acd9cc8ced1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-31 16:58:36 +01:00
Lars Knoll ddba8f6bb0 Conformant implementation of the object internal methods
See section 8.12 of the standard. This implements
8.12.1 - 8.12.7 and 8.12.9

Also gave these methods standard conformant names.
They are marked as [[foo]] in the standard, which
translates to __foo__ in our code.

Change-Id: I1990d6c6dd24e929c23d5c51d36f1e2e0a0a3b63
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-31 16:57:24 +01:00
Lars Knoll 950e4f70a3 Add a Value::sameValue() method
This implements Section 9.11 of the spec.
Also simplify __qmljs_strict_equal().

Change-Id: I99b33308c33f4d4732b4a72bd5327336b2b22257
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-31 12:48:04 +01:00
Lars Knoll aa96410f3f Rework properties
This brings the basic structure or accessing properties
more in line with the EcmaScript 5.1 specification.

There's however still quite some work to be done to
make things fully compliant.

Change-Id: If55afd7ae6e4f7aa5ce06afe49b1453b537ac98b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-31 12:46:49 +01:00
Lars Knoll 577cbfa2ee Added basic support for 'for (var x in y)' statement
Change-Id: I8f3c8add78bebf92e0073348d1ecbdf3f328af6d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-31 12:45:49 +01:00
Lars Knoll 04b12a90b8 Implement regexp support
Change-Id: I86c9bbe69c9ba4ae9d300b62e7d16b372f3478ea
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-20 12:33:20 +02:00
Lars Knoll e5473687ec Cleanup
Remove __qmljs_init_object and replace it with
Value::fromObject

Change-Id: Ibc8bd9e7ecd56c6713dc08add72e5cd35ffea78e
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-18 10:33:34 +02:00
Lars Knoll c63e799fc2 Convert Value constructors to new calling convention
Change-Id: I433f72666499e660618b061cfcf3407f5f9bb166
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2012-10-16 16:57:01 +02:00
Simon Hausmann c13a95361a Add missing license headers
Change-Id: I59d602a0f2c1fefb03994ed32a3d697b176791ff
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
2012-10-12 10:51:06 +02:00
laknoll aaea2a9a96 Proper NaN boxing for Value
All JS types are now encoded in a 8 byte data
structure. We use the 52 bits that are unused
when a double is a NaN to encode all other types
that can be stored inside a double.

This is being done by using a few bits to determine
the type, and up to 48 bits for data. This works
even on x64, as addresses (ie. pointers) are limited
to 48 bits on these platforms.

For most other types (except doubles), we store the
data in the lower 32 bits of the double.
2012-09-19 23:28:50 +02:00
Roberto Raggi 48a0b3c96b Do not try to optimize the `global object'.
This should simplify the implementation of `eval' and `with'.
2012-06-26 15:17:31 +02:00
Aaron Kennedy 6ce83a38c9 Begin to implement moth vm 2012-06-12 18:14:13 +01:00
Roberto Raggi 810011f45a Improve support for the assignment operators.
Also, use indirect calls in the amd64 code generator.
2012-06-11 09:38:52 +02:00
Roberto Raggi bf46892ccd Move the defnition of the QML/JS Context to qmljs_runtime.h 2012-06-05 10:47:04 +02:00
Roberto Raggi 66a9d37813 Naive implementation of the Arguments object. 2012-06-04 16:36:00 +02:00
Roberto Raggi 51dcef5cdf Implemented Object.getPrototypeOf and Object.prototype.valueOf 2012-06-04 15:57:39 +02:00
Roberto Raggi 08bd3ea09a Initial work on the RegExp object 2012-06-04 15:34:50 +02:00
Roberto Raggi 968b80267f Initial work on [[HasProperty]] 2012-06-04 13:44:37 +02:00
Roberto Raggi 538ed5c57c Generate cx-instructions for releational expressionsa. 2012-05-30 12:42:27 +02:00
Roberto Raggi b25e575ba0 Fix [[construct] and Object.prototype.toString 2012-05-28 22:16:21 +02:00
Roberto Raggi 5b0f452f4d Implement instanceof 2012-05-28 20:17:13 +02:00
Roberto Raggi 7e7df11464 Fix the initialization of the ECMA library. 2012-05-25 17:45:15 +02:00
Roberto Raggi fc6f96166f Refactored Object 2012-05-25 13:43:30 +02:00
Roberto Raggi a5229e821d Propagate exceptions 2012-05-25 11:55:50 +02:00
Roberto Raggi 3bc997b2e3 Throw exceptions in the ecma library 2012-05-24 10:01:24 +02:00
Roberto Raggi 86183598a3 Throw exceptions 2012-05-23 18:50:24 +02:00
Roberto Raggi b29b7aaa60 Initialize functionPrototype. 2012-05-21 18:44:36 +02:00
Roberto Raggi 88d8a47305 Set the prototype of script and native functions. 2012-05-21 15:16:19 +02:00
Roberto Raggi 0388eb704a Initial work on the Function prototype. 2012-05-21 14:58:23 +02:00
Roberto Raggi 6448ae090f Fix prototypes and implemented isel for constructValue. 2012-05-21 10:09:41 +02:00
Roberto Raggi 945c988b45 Initial support for Array objects. 2012-05-21 09:52:55 +02:00
Roberto Raggi 860bd23e4d Improve [[DefaultValue]] 2012-05-18 15:28:59 +02:00
Roberto Raggi ccebbc0641 Implemented the ecma Date object. 2012-05-18 14:10:02 +02:00
Roberto Raggi 086e775da6 Some refactoring and some initial work on the Date object. 2012-05-18 10:10:36 +02:00