Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump() needs to deal with Objects better #35

Closed
gfwilliams opened this issue Oct 1, 2013 · 2 comments
Closed

dump() needs to deal with Objects better #35

gfwilliams opened this issue Oct 1, 2013 · 2 comments
Labels

Comments

@gfwilliams
Copy link
Member

It has to be aware of scope/proto elements and JSV_PARENTINFO so that it can rebuild code snippets that contain heavier Object orientation.

@gfwilliams
Copy link
Member Author

This is an interesting case of dump() being stupid as well: http://forum.espruino.com/conversations/329745

function Test() {
  console.log("Hello");
}
Test.prototype.foo = function() {
  console.log("Hello 2");
};

a = new Test();
delete Test; // we've now lost the original 'Test'
dump();
// outputs just:
// var a = Object.create(a.__proto__.constructor["prototype"]);

then...

A = Object.getPrototypeOf(a).constructor;
dump();
// outputs:
// var a = Object.create(a.__proto__.constructor["prototype"]);
// function A() {console.log("Hello");}
// A.prototype.foo = function () {console.log("Hello 2");};
  • First off, it's doing a depth first rather than breadth-first search for the class to use, which reconstructs stuff really badly.
  • Then a actually ends up referencing itself in the first instance - Espruino should detect this and instead create a new temporary Class name to output first.
  • It'd actually be neat if dump() could take an argument which is the variable to 'start' from - it'd allow you to (for instance) dump just a single class.

@gfwilliams
Copy link
Member Author

Closing this - it seems with the ability to save raw JS to flash I don't think many people are using this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant