1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00
Commit Graph

614 Commits

Author SHA1 Message Date
Robert Krimen
6c7c425424 Fix toReflectValue to handle Struct, Map, Slice, etc.
This fixes #79
2014-06-04 18:08:42 -07:00
Robert Krimen
1a2fa0b815 Fix "Halting Problem" example
As discussed in #71, the original example contains a race condition that could cause the goroutine to block forever.
2014-05-31 13:38:11 -07:00
Robert Krimen
f09ce5eac2 Add mutex locking for .Copy() 2014-05-30 20:27:30 -07:00
Robert Krimen
98be5e74da go vet
This fixes #76

I cheated on some of these.
2014-05-28 21:46:08 -07:00
Robert Krimen
918abeb8d8 The zero value of Value is now defined to be undefined
Previously, it was a publically accessible but invalid value (valueEmpty).

* Deprecate internal use of UndefinedValue(), NullValue(), FalseValue(), TrueValue()
* Guard against Empty, Result, Reference values from escaping the package
2014-05-28 21:23:32 -07:00
Robert Krimen
526d3b2fd5 Minor cloning adjustments
Mostly cosmetic.
2014-05-27 22:09:57 -07:00
Robert Krimen
9cd045ef04 Simplification & refactor of (parts of) the runtime
* Proper lowercasing for internal stuff
* *Environment => *_stash
* ExecutionContext => _scope
* Simpler & shallower call/construct mechanics
* Remove unnecessary fields & methods
* Better scoping (no more stack): []*_scope => _scope.outer
* Some speed improvements

In preparation for #66
2014-05-27 22:05:35 -07:00
Robert Krimen
b7dd9df181 Fix array-like handling in JSON.stringify
This fixes #73
2014-05-24 10:05:10 -07:00
Robert Krimen
ba678bc782 Use _runtime.toValue() instead of func toValue()
This fixes #72
2014-05-22 20:39:27 -07:00
Igor Kharin
1864a88fa0 Implement strings without value16
This fixes #68

Some changes over the original patch, removing references to utf8string.String:

* (better) This removes a dependency on a non-standard (though solid) package
* (better) utf8string.String has mutable parts
* (worse) utf8string.String has a smarter consecutive access approach (by
  remembering where the last access was)
* (?) _stringWide allocates a []rune if charAt or charCodeAt access is needed (though
  it will only do this once for the string object)
2014-05-18 12:38:15 -07:00
Robert Krimen
6d506b4b2f Update documention to mention natto 2014-04-26 22:49:27 -07:00
Robert Krimen
058fe32c29 terst 2014-04-26 22:19:01 -07:00
Robert Krimen
70f432f8d5 terst 2014-04-26 11:52:14 -07:00
Robert Krimen
a15d66ea64 Fix missing interrupt 2014-04-25 23:04:44 -07:00
Robert Krimen
470b8c3b73 terst
* Update to latest github.com/robertkrimen/terst
* Clean up testing
2014-04-25 22:48:25 -07:00
Robert Krimen
bf7b16f4a3 Add internal compilation step
* Streamline what we get from "otto/parser"
* Get rid of some "otto/parser" cruft
* FunctionExpression => FunctionLiteral
* The debugger statement (debugger) should do nothing (not panic)
* Fix aspects of function expression call evaluation
2014-04-19 14:05:51 -07:00
Robert Krimen
0917510923 Fix delete ... triggering property get() 2014-04-19 11:11:53 -07:00
Robert Krimen
8aca2c886a Disable script marshalling/unmarshalling for now 2014-04-15 18:34:24 -07:00
Robert Krimen
142951ac5a Add Script marshalling/unmarshalling 2014-04-13 19:47:23 -07:00
Robert Krimen
9561f66959 Tighten test comparisons instead of squashing everything to a string 2014-04-13 18:09:46 -07:00
Robert Krimen
7721396b67 Fix Date tests to always mock UTC 2014-04-13 15:07:29 -07:00
Robert Krimen
ddca88af9b Add compilation (Script, vm.Compile, etc.) 2014-04-13 15:04:32 -07:00
Robert Krimen
7163cd7841 Skip unexported fields, begin json.Marshaler support
* The "reflect" package is willing to expose unexported fields in structs (a little suprising).
* Skip unexported fields when enumerating or trying to access (pretend they don't exist).
* Allow structs that implement json.Marshaler to work as expected in a JSON.stringify call.

If we let the runtime try to access unexported fields, it'll cause a panic.

This fixes #64
2014-04-12 11:53:04 -07:00
Robert Krimen
ba4c8b0769 Fix documentation 2014-04-11 18:23:34 -07:00
Robert Krimen
9d7eadf70f Simplify the commandline client (otto) 2014-04-11 18:13:46 -07:00
Robert Krimen
f04cfab02d Add ability to parse []byte, *bytes.Buffer, io.Reader 2014-04-11 18:07:57 -07:00
Robert Krimen
6e3ed1b99d Tighten test comparisons instead of squashing everything to a string 2014-04-11 18:06:18 -07:00
Robert Krimen
029f0bbd63 Fix parseInt if ErrRange occurs (fallback to float64) 2014-04-11 18:05:54 -07:00
Robert Krimen
ad8a97c028 New parser
* Faster, more straightforward, etc.
* More advanced object literals (get ..., set ...)
* More tests using JavaScript from the wild (http://cdnjs.com/)
2014-04-10 20:42:25 -07:00
Robert Krimen
ec106f69e0 Add Object.Keys()
This fixes #62
2014-04-03 18:25:53 -07:00
Robert Krimen
0c82879349 Stop checking against 1.0.3 for release 2014-03-16 09:05:28 -07:00
Daniel Cannon
07737f86b9 Add ability to call struct methods
This fixes #60

This is incompatible with go 1.0.3
2014-03-16 09:04:00 -07:00
Daniel Cannon
661a61c5a0 Fix toValue not properly converting type aliases
This fixes #61
2014-03-16 08:46:20 -07:00
Robert Krimen
6f0e24ae2d Fix Array.prototype.reduce, .reduceRight
Fix false-positives in underscore testing
Fix test (missing document because we're not in a browser)
2014-03-13 22:39:17 +01:00
Robert Krimen
73cdc7031e newnewNode => newNewNode 2014-02-21 23:06:20 -08:00
Robert Krimen
aef9bfcb9a Fix "memory leak" by gelcapping panic values with _exception
Basically, the Go runtime sees the gelcap shell of the exception,
which dissolves (payload is set to nil) once we catch the error.

This prevents the Go runtime from hanging onto a heavy object for the
panic log (or whatever it is doing with the panic value).

This fixes #59
2014-02-21 18:24:07 -08:00
Robert Krimen
1f3aef2086 Fix Date.prototype.setTime
This fixes #58
2014-02-18 20:37:54 -08:00
Robert Krimen
e01dde79ed More tests for .Copy()
This fixes #57
2014-02-16 21:41:16 -08:00
Robert Krimen
70e6bec5e0 Make sure to set the Otto/runtime dependency when copying
This is a problem in #57
2014-02-16 21:22:30 -08:00
Robert Krimen
2ea54739df terst 2014-02-16 11:07:10 -08:00
Robert Krimen
5aa653244a Fix Put to see set/get properties 2014-02-15 10:20:33 -08:00
Robert Krimen
333bb23c07 Guard against _nilGetSetObject sneaking in 2014-02-14 23:23:39 -08:00
Robert Krimen
99263cd960 Clarify AccessorDescriptor logic in DefineOwnProperty even more 2014-02-14 22:33:27 -08:00
Robert Krimen
acf0a991f7 Can set a setter/getter if absent (8.12.9 / 10.a.ii.1) 2014-02-14 22:23:15 -08:00
Robert Krimen
87a212ca60 Fix for get/set: undefined is actually a getter/setter 2014-02-14 21:47:50 -08:00
Robert Krimen
7a2ed55010 Fix assumption that property.value is Value 2014-02-14 20:06:31 -08:00
Robert Krimen
9c45463cd6 Preserve existing get/set unless explicitly undefined 2014-02-14 19:46:37 -08:00
Robert Krimen
ee1cce94ef If set === undefined => writable = false 2014-02-13 21:38:20 -08:00
Robert Krimen
57e0a468ac Fix a few aspects of accessor properties 2014-02-13 21:30:26 -08:00
Tim Jurcka
dd88ce83b8 Call getter/setter if property is AccessorDescriptor
This fixes #36
This fixes #56
2014-02-12 21:52:42 -08:00