Git Product home page Git Product logo

pypyjs / pypy Goto Github PK

View Code? Open in Web Editor NEW
33.0 33.0 10.0 246.36 MB

Fork of https://bitbucket.org/pypy/pypy with support for compiling to javascript

License: Other

Makefile 0.04% Python 93.76% HTML 0.23% C 4.90% Shell 0.01% Batchfile 0.02% Visual Basic 0.01% C++ 0.57% CSS 0.01% Emacs Lisp 0.01% Assembly 0.33% JavaScript 0.05% HCL 0.01% PLSQL 0.05% Roff 0.02% Objective-C 0.01% Vim Script 0.01%

pypy's Introduction

PyPy.js: PyPy compiled into JavaScript

Note: Development is sleeping at the moment. Discuss this here: #213. Look at iodide (specifically, pyodide) for a maintained and heavily developed alternative.

PyPy. Compiled into JavaScript. JIT-compiling to JavaScript at runtime. Because why not.

This is a very-much-in-flux collection of supporting scripts and infrastructure for an experimental emscripten/asmjs backend for PyPy. You can read more about the project (and try it out live!) here:

http://pypyjs.org/

If you just want to use a pre-compiled PyPy.js interpreter, please download a release bundle from the above website and follow the instructions in the included README.

If you're like to work on the PyPy.js code itself, please see the details in CONTRIBUTING.rst. All code is available under the MIT License.

For the history of the project, see NEWS.

Repository Overview

pypyjs Main repository to built a PyPy.js release
pypy Fork of PyPy with support for compiling to javascript
pypyjs-release Latest release build of PyPy.js, as a handy git submodule
pypyjs-release-nojit Latest release build of PyPy.js, without a JIT
pypyjs-examples Examples/snippets usage of pypyjs-release and pypyjs-release-nojit
pypyjs.github.io source for pypyjs.org website use pypyjs-release and pypyjs-release-nojit

pypy's People

Contributors

alex avatar amauryfa avatar anders-chrigstrom avatar antocuni avatar aquamiau avatar arigo avatar bdkearns avatar benjaminp avatar bivab avatar cfbolz avatar ctismer avatar ericvrp avatar fijal avatar groggi avatar hakanardo avatar hpk42 avatar jlg avatar jpeel avatar lac22 avatar mattip avatar mwhudson avatar nikomatsakis avatar pedronis avatar pjenvey avatar ptersilie avatar rguillebert avatar richemslie avatar rlamy avatar santagada avatar wlav 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pypy's Issues

Adding a function to the js module

I've been working on getting the pypy vm built with emterpreter enabled to get synchronous functions to work. I've added a function to the js module to synchronously await a promise.

But now I'm running into a compile error that I can't figure out.

This is the error: (I'll add the stacktrace to the end)

[translation:ERROR] ValueError: argument to ll function pointer call: should return a low-level type,
[translation:ERROR] got instead SomeInstance(can_be_None=True, classdef=pypy.interpreter.baseobjspace.W_Root)

I added this to emjs.h

//Synchronously await a promise
emjs_handle emjs_await(emjs_handle promise);

and then this to library_emjs.js

  emjs_await__deps: ['emjs_deref', '$EmterpreterAsync'],
  emjs_await: function(promise_h) {
    var promise = _emjs_deref(promise_h);
    EmterpreterAsync.handle(function(resume) {
      promise.then(function(val) {
        if (ABORT) return;  
        resume(val);
      }, function(err) {
        if (ABORT) return;
        EMJS.last_error = err;
        resume(EMJS.ERROR);
      });
    });
  },  

And this to support.py (what does random_effects_on_gcobjs mean?)

@jsexternal([EMJS_HANDLE_TP], EMJS_HANDLE_TP,
            random_effects_on_gcobjs=True)
def emjs_await(h_prom):
    raise NotImplementedError

I added this to interp_js.py

def await(space, w_promise): 
    """Await a javascript promise."""
    h = support.emjs_await(w_promise)
    return _wrap_handle(space, h)

And this to init.py: 'await': 'interp_js.await'

stacktrace:

[translation:info] Error:
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/translator/goal/translate.py", line 318, in main
[translation:info]     drv.proceed(goals)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/translator/driver.py", line 559, in proceed
[translation:info]     return self._execute(goals, task_skip = self._maybe_skip())
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/translator/tool/taskengine.py", line 114, in _execute
[translation:info]     res = self._do(goal, taskcallable, *args, **kwds)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/translator/driver.py", line 277, in _do
[translation:info]     res = func()
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/translator/driver.py", line 314, in task_annotate
[translation:info]     s = annotator.build_types(self.entry_point, self.inputtypes)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/annrpython.py", line 89, in build_types
[translation:info]     return self.build_graph_types(flowgraph, inputcells, complete_now=complete_now)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/annrpython.py", line 135, in build_graph_types
[translation:info]     self.complete()
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/annrpython.py", line 189, in complete
[translation:info]     self.complete_pending_blocks()
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/annrpython.py", line 184, in complete_pending_blocks
[translation:info]     self.processblock(graph, block)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/annrpython.py", line 336, in processblock
[translation:info]     self.flowin(graph, block)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/annrpython.py", line 408, in flowin
[translation:info]     self.consider_op(op)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/annrpython.py", line 582, in consider_op
[translation:info]     resultcell = op.consider(self)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/flowspace/operation.py", line 104, in consider
[translation:info]     return spec(annotator, *self.args)
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/annotator/unaryop.py", line 52, in simple_call_SomeObject
[translation:info]     simple_args([annotator.annotation(arg) for arg in args]))
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/rtyper/lltypesystem/lltype.py", line 1575, in call
[translation:info]     for s_arg in args_s]
[translation:info]    File "/home/albertjan/pypyjs/deps/pypy/rpython/rtyper/llannotation.py", line 168, in annotation_to_lltype
[translation:info]     info, s_val))
[translation:ERROR] ValueError: argument to ll function pointer call: should return a low-level type,
[translation:ERROR] got instead SomeInstance(can_be_None=True, classdef=pypy.interpreter.baseobjspace.W_Root)
[translation:ERROR] Processing block:
[translation:ERROR]  block@9 is a <class 'rpython.flowspace.flowcontext.SpamBlock'>
[translation:ERROR]  in (pypy.module.js.interp_js:953)await
[translation:ERROR]  containing the following operations:
[translation:ERROR]        h_0 = simple_call((<* fn emjs_await>), w_promise_0)
[translation:ERROR]        v557 = simple_call((function _wrap_handle), space_92, h_0)
[translation:ERROR]  --end--

add changes in a seperate branch?!?

It's not directly clear what changes for PyPy.js was made.

What's about to made all changes in a separate branch? So it's possible to use the github compare view ;)

compiling python3 error

When I compile the python 3 version, the report is wrong translate: error: invalid value javascript for option backend and translate: error: invalid value js for option backend

How do I compile the python 3 version of the pypyjs file correctly?

py3k branch missing

Hey @rfk I opened an issue about this somewhere but I can't find it anymore. I just wanted to give a very gentle reminder that you were going to push the py3k branch for pypy to this repo. Thanks!

Error: expected string, got String object

getattr(a js object, attr_name) seems not to work as excepted.

Test code:

import js

jquery = js.globals["$"]
print "isReady 1:", jquery.isReady
print "isReady 2:", getattr(jquery, "isReady")

for attr_name in jquery:
    print "%20s:" % attr_name,
    try:
        print getattr(jquery, attr_name)
    except Exception as err:
        print "Error: %s" % err

will output:

isReady 1: true
isReady 2: true
                  fn: Error: expected string, got String object
              extend: Error: expected string, got String object
             expando: Error: expected string, got String object
          noConflict: Error: expected string, got String object
             isReady: Error: expected string, got String object
...

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.