Git Product home page Git Product logo

jsjs-vm-demo's People

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

Watchers

 avatar  avatar

jsjs-vm-demo's Issues

for-in支持

感谢作者大大的指引,我们团队已经fork了项目并且进行了部分缺陷的修复。以下为for-in的支持:

      /**
       * convert
       * for (var a in o) { body }
       * to
       * Object.values(o).forEach(function (a){ body })
       */
      case 'ForInStatement': {
        this.compileStatement({
          type: 'ExpressionStatement',
          expression: {
            type: 'CallExpression',
            callee: {
              type: 'MemberExpression',
              object: {
                type: 'CallExpression',
                callee: {
                  type: 'MemberExpression',
                  object: { type: 'Identifier', name: 'Object' },
                  property: { type: 'Identifier', name: 'values' },
                  computed: false,
                  optional: false,
                },
                arguments: [{ type: 'Identifier', name: (stat.right as Identifier).name }],
                optional: false,
              },
              property: { type: 'Identifier', name: 'forEach' },
              computed: false,
              optional: false,
            },
            arguments: [{
              type: 'FunctionExpression',
              id: null,
              params: [{ type: 'Identifier', name: ((stat.left as VariableDeclaration).declarations[0].id as any).name }],
              body: {
                type: 'BlockStatement',
                body: [stat.body]
              },
              label: this.createLabelName('for_in_func'),
              declarations: new Set(),
            }],
            optional: false,
          }
        })
        this.writeOp(OpCode.RET)
        this.compileBlock({
          type: 'FunctionExpression',
          id: null,
          params: [{ type: 'Identifier', name: ((stat.left as VariableDeclaration).declarations[0].id as any).name }],
          body: {
            type: 'BlockStatement',
            body: [stat.body]
          },
          label: this.createLabelName('for_in_func'),
          declarations: new Set(),
        })
        break;
      }

代码含二元表达式存在问题

当测试代码片段含有二元表达式时存在死循环问题,如:

var test = function (a, b){
   return a > 20 ? a : b
}
console.log(test(10, 1))

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.