* Add make_fn macro in builtins module
* Replace all array methods with the make_fn macro
* Set builtins method with make_fn for bool, console, error, json, math, number, object, regexp and string
* Rename make_fn macro to make_builtin_fn
* Rename the actual macro rule to make_builtin_fn
* make_builtin_fn macro without length will result to length 0
* Add length property for every builtin method
* Remove duplicate definition of toString method in regexp
* Add missing length attributes to builtins methods
* Added the initial implementation for Array.prototype.map
* Removed unneccessary .to_string()
* Fixed clippy errors
* Fixed old array being modified by `map`
* rustfmt
* Refactored `map` to use iter().map()
* Refactored array.prototype.map
* Feature(Number): Tests for the Test Driven Development!
refs #34
* Feature: Skeleton code for Number
refs #34
* Feature: Most of Number() is complete
Includes:
- make_number()
- call_number()
- Number().toExponential()
- Number().toFixed()
- Number().toLocaleString() (ish)
- Number().toString()
- Number().valueOf()
- create_constructor()
- init()
Missing:
- Number().toPrecision()
refs #34
* Feature(Number): test compatability with const -> var
I don't have all the context on _why_ but all of the tests for `Number` started failing.
Upon investigation it was becuase `const` stopped acting the way I expected.
Switching my test cases from using `const` to using `var` variable declarations
made everything work again. I don't know enough about JS to know if this is a
bug or expected behavior. Based on changes to other tests, it is know
behavior.
Refs #34
* Changelog: Number() object.
Includes some clippy fixes.
Fixes#34
* Array.prototype.fill method implementation
* Added types
* Fmt changes
* Fill tests fixed - let to var change
* Added support for string arguments
* Formatting
* Replaced set_field_slice with set_field
* Parse args to int change
* More tests and bug fixes
* Removed print
* Removed unnecessary else block
* Calling function to get ValueData::Undefined in GC
* Fmt update
* Function length prop, variable name change, and one more test
* Removed duplicated test case
* Implement block scoped variable declarations
`const` and `let` are now scoped to the block, while `var` is scoped to
the surronding function (or global).
Another bigger change is that all tests have been changed to use `var`
instead of `let` or `const`. This is because every time `forward` is
called with some new Javascript to evaluate, we parse it as a block,
hence variables can only persist across calls to `forward` if they are
defined using `var`. I assume it is intentional to parse each call as a
separate block, because a block is the only `ExprDef` which can contain
multiple statements.
Closes#39
* Prefer environment parent over environment_stack
Instead of iterating over the `environment_stack` we rather use
`get_outer_environment` as it will be a better fit when asyncronous
functions are implemented.
* Ensure variable from outer scope is assigned
Variables that are defined outside a block should be changeable within
the scope. Just because variable is undefined does not mean it is not
initialized.