Skip to content

Implemented function expressions - #382

Merged
Razican merged 1 commit into
masterfrom
function_expr
May 9, 2020
Merged

Razican merged 1 commit into
masterfrom
function_expr

Conversation

@Razican

@Razican Razican commented May 7, 2020 •

Copy link
Copy Markdown
Member

This also adds the name property to functions. It fixes #266 and makes progress towards #12.

There is one extra thing that is not solved though:

let a = function() {};
a.name;

This should show a, but this is currently not happening. I guess that the solution is to change the assignment expression to change the name of the function.

I duplicated most of the execution code for declarations/expressions, though, this can probably be improved in the future. I used this to set the name of the function:

val.set_field_slice("name", to_value(name.clone()));

This is not super spec compliant, but do you think it's good for now?

@Razican Razican added A-Bug Something isn't working A-Enhancement New feature or request labels May 7, 2020
@Razican Razican added this to the v0.8.0 milestone May 7, 2020
@github-actions

github-actions Bot commented May 7, 2020

Copy link
Copy Markdown

Benchmark for de95f3e

Click to view benchmark
Test PR Benchmark Master Benchmark %
Create Realm 485.0±22.54µs 486.3±13.93µs 100%
Expression (Lexer) 1990.8±75.35ns 1981.3±19.24ns 100%
Expression (Parser) 5.3±0.13µs 5.1±0.11µs 104%
Fibonacci (Execution) 3.3±0.15ms 3.3±0.03ms 101%
For loop (Execution) 503.6±19.15µs 505.9±8.71µs 100%
For loop (Lexer) 5.4±0.13µs 5.5±0.15µs 99%
For loop (Parser) 14.5±0.17µs 14.3±0.26µs 101%
Hello World (Lexer) 959.5±9.42ns 969.6±12.91ns 99%
Hello World (Parser) 2.3±0.06µs 2.4±0.10µs 97%
Symbols (Execution) 514.4±18.44µs 513.7±13.37µs 100%
undefined undefined 100%

This also adds the `name` property to functions.
@github-actions

github-actions Bot commented May 7, 2020

Copy link
Copy Markdown

Benchmark for decbee6

Click to view benchmark
Test PR Benchmark Master Benchmark %
Create Realm 473.6±21.62µs 466.7±18.62µs 101%
Expression (Lexer) 1929.9±73.77ns 1912.0±69.85ns 101%
Expression (Parser) 5.2±0.16µs 4.9±0.15µs 104%
Fibonacci (Execution) 3.2±0.07ms 3.2±0.05ms 100%
For loop (Execution) 485.1±9.86µs 489.8±15.09µs 99%
For loop (Lexer) 5.2±0.19µs 5.2±0.09µs 101%
For loop (Parser) 13.9±0.33µs 13.8±0.38µs 101%
Hello World (Lexer) 944.3±47.82ns 935.7±47.56ns 101%
Hello World (Parser) 2.2±0.05µs 2.2±0.03µs 99%
Symbols (Execution) 500.4±11.00µs 494.6±10.50µs 101%
undefined undefined 100%

@Razican
Razican requested review from HalidOdat and jasonwilliams and removed request for jasonwilliams May 9, 2020 11:52
@Razican
Razican merged commit 9c9c463 into master May 9, 2020
@Razican
Razican deleted the function_expr branch May 9, 2020 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Bug Something isn't working A-Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic assigning named function to variable

2 participants