Coder Social home page Coder Social logo

flathead's People

Contributors

finwo avatar jpiccari avatar ndreynolds avatar pstef avatar tcort avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flathead's Issues

embedded OS porting

Hello,I want porting this componet to RTOS,but this source code hava too much stdio/FILE and so on func,
what can I do?

Expand RegExp literals

The current lexer for RegExp literals is pretty basic:

https://github.com/ndreynolds/flathead/blob/master/src/lexer.l#L116-119

It doesn't allow any spaces or forward slashes, but those should be allowed. It needs to be expanded to support the full grammar as given in the spec.

  • One of the issues is differentiating RegExp literals from expressions with the division operator (see this StackOverflow post).
  • Flex's start conditions might be a good fit for this.
  • The lexer doesn't need to verify that the RegExp is actually valid, we can let PCRE handle that when we attempt to compile it.

Implement the Function constructor

Add the body to func_new in Function.c and new tests to test_function_global.js according to the spec. For example:

(new Function('x', 'y', 'return x * y'))(2, 2)
// 4

The trouble with this one is parsing the function body that's given as the last argument. It's going to need to get routed through Flex and Bison. There's a proof-of-concept load function that treads in this water, but it needs some more work itself.

Segmentation fault at src/eval.c:374

Hi team,

I found a segmentation fault error at src/eval.c:374( at function assign's first line).

Reproduction:

$ /path/to/flathead/bin/flat trigger.js

The content of trigger.js is :

var a =0[1,2];

ubuntu 12.04.2

make test
bin/test --dir test -x bin/flat
/usr/bin/env: node: 没有那个文件或目录
make: *** [test] 错误 127

ReferenceError on a valid code.

var result = [];
for (var i=0; i<2; i++) {
    (function () {
        var copy = i;
        var func = function () {
            return copy;
        };
        result.push(func);
    }());
}

console.log(result[0]());

Flat will report Reference error while node engine does not:

$ ./flathead/bin/flat ./test.js 
ReferenceError: copy is not defined
  at ./test.js:6:10
  at (anonymous function) in ./test.js:12:22
$ node ./test.js 
0

Implement try and throw statements

Implement the try and throw statements (along with catch and finally) as specified in ES5.1 12.13 and 12.14.

The productions for these statements have already been added to the Bison grammar:

https://github.com/ndreynolds/flathead/blob/master/src/grammar.y#L445-467

To get try, throw and friends working, the existing state trace will probably need to be expanded to store pointers to evaluation states. We'll need to add new cases to the switch statement in eval.c and likely a few new functions below those for the implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.