Commit Graph

527 Commits

Author SHA1 Message Date
Windel Bouwman
4c5b5845bb Merge pull request #244 from coolreader18/boxed-rustfunc
Change RustPyFunc from a fn pointer to a Fn trait
2018-12-27 20:23:22 +01:00
AgentMacklin
79a3b13252 Implement most of the string methods. (#239)
* implemented more functions

* backup

* Improve demo site

* Formatting; move the `+ '\n'` hack to eval().

* Rename run_code() to run_from_textbox()

* Switch to using json.dumps for py_to_js()

* Clarify names of wasm builtins

* Remove dependency on num_bigint

* Allow injecting JS variables into python with eval_py()

eval_py(`return js_vars["a"]`, { a: 9 }) == 9

* dict() now should work properly

e.g.
``` dict(a=2, b=3) == {"a": 2, "b": 3} ```

* Add documentation for eval_py() and update error message handling

Also, switch from iterating over the values of js_injections and
serializing each of them individually to asserting it's an object and
then just stringifying the whole thing.

* Finish revamping `dict_new()`

* Add 'from x import *' syntax.

This is a separate opcode in CPython so I added it as such here.

* Add test for dicts

* added functions

* ran rustfmt and fixed isidentifier

* fixed zfill and make_title

* python3.6 doesn't contain isascii()
2018-12-27 20:22:04 +01:00
coolreader18
09602a2ec6 Change RustPyFunc from a fn pointer to a Fn trait 2018-12-27 09:18:00 -06:00
Windel Bouwman
f325ef1499 Merge pull request #240 from coolreader18/json-error
Have the json ser/de functions throw an exception instead of panicking
2018-12-27 09:20:52 +01:00
coolreader18
8fee5a8800 Run cargo fmt --all 2018-12-27 00:12:08 -06:00
coolreader18
0ac0432a53 Run cargo fmt 2018-12-26 18:23:40 -06:00
coolreader18
80573b0544 Format PyObject's correctly and nicely 2018-12-26 18:09:49 -06:00
coolreader18
d1a584f0fd Don't allocate a new string for each new type for the ExceptionZoo 2018-12-26 14:19:19 -06:00
coolreader18
a77b7e0ce4 Have json.* throw an exception instead of panicking 2018-12-26 14:18:15 -06:00
Windel Bouwman
946df53077 Merge pull request #237 from johndaniels/add-star-import
Add 'from x import *' syntax.
2018-12-23 17:55:34 +01:00
Gitea
ac3da8b453 Add 'from x import *' syntax.
This is a separate opcode in CPython so I added it as such here.
2018-12-22 22:40:02 -05:00
Windel Bouwman
366f3e2b13 Merge pull request #236 from coolreader18/proper-dict
Make `dict()` work like it does in cpython
2018-12-22 16:05:31 +01:00
coolreader18
f1784236af Finish revamping dict_new() 2018-12-21 23:35:45 -06:00
coolreader18
bdc80dc75b dict() now should work properly
e.g.
``` dict(a=2, b=3) == {"a": 2, "b": 3} ```
2018-12-18 01:34:00 -06:00
Windel Bouwman
950dbd1a77 Use new_list when constructing multiplied list. 2018-12-17 12:14:29 +01:00
Windel Bouwman
bbe333d6c7 Merge pull request #233 from rossjones/232-impl-mul-for-list
Implements __mul__ for lists
2018-12-17 11:55:44 +01:00
Gitea
a6288acd22 Cargo format. 2018-12-16 15:48:59 -05:00
Ross Jones
ae2f7ed1cb Implements __mul__ for lists
Implements __mul__ for lists so that it is possible to do things like

```
s = [1, 2,] * 3
s == [1, 2, 1, 2, 1, 2]
```
2018-12-16 12:22:31 +00:00
Gitea
b726e675ff Add format builtin and String formatting stuff.
This includes everything needed to call str.format with integers
as positional and keyword parameters.
2018-12-15 19:46:09 -05:00
Windel Bouwman
62c53d8e5d Try to make it simpler to switch dict storage types. 2018-12-13 20:38:09 +01:00
Windel Bouwman
521f664e16 Merge pull request #229 from AgentMacklin/master
Added some of the missing str methods
2018-12-13 20:31:45 +01:00
Austen LeBeau
7ac22d96d1 update and added more functions 2018-12-13 12:02:18 -06:00
Windel Bouwman
a29e882bc1 Store dict key as pyobject into hashmap. 2018-12-13 17:05:01 +01:00
Windel Bouwman
e657633e51 Move set_item to context struct. 2018-12-12 22:27:28 +01:00
Windel Bouwman
4095e0cad7 Modify location of set_attr so that we are able to create str python objects for the dictionary. 2018-12-12 22:06:19 +01:00
Windel Bouwman
0215830aaa Move set_attr and set_item to context. 2018-12-12 19:41:09 +01:00
Austen LeBeau
dd2b4e3c25 added isalnum, isalpha, isdigit, swapcase 2018-12-12 12:01:35 -06:00
Windel Bouwman
5c04ad8aae Make underlying dict type more hidden. 2018-12-12 15:13:40 +01:00
Austen LeBeau
07336fa984 initial fork commit 2018-12-11 22:44:56 -06:00
Shing Lyu
5734fc29ca Merge pull request #203 from RustPython/consolelog
Mapping Python print to JavaScript console.log
2018-12-03 20:48:43 +01:00
Shing Lyu
2c55c4793e [WASM] Mapping print to console.log 2018-12-03 19:51:48 +01:00
Windel Bouwman
8eacbcbc06 Add builtins to sys.modules. Add __float__ method to int class. 2018-11-26 22:31:40 +01:00
Windel Bouwman
f227ce0498 Add random module 2018-11-25 23:20:10 +01:00
yodalee
68892fb4e2 fix rustfmt 2018-11-25 22:13:26 +08:00
yodalee
04548db1e0 add implementation of special math function
function include: erf, erfc, gamma, lgamma
use package statrs' implementation
2018-11-25 20:10:34 +08:00
Windel Bouwman
be462afaa4 Add method to list and tuple class. 2018-11-17 12:31:24 +01:00
Bojan
0da1f73777 Removed empty space 2018-11-16 07:49:12 +01:00
Bojan
d972b07195 Fixed method comment 2018-11-15 23:47:11 +01:00
Bojan
f9860d083e Moved and to use new method 2018-11-15 23:42:17 +01:00
Bojan
15c6328ecd Moved sub to use new method 2018-11-15 23:42:03 +01:00
Bojan
05d2faa227 Added call_or_unsupported to vm.rs
This is to prevent code duplication
2018-11-15 23:37:46 +01:00
Windel Bouwman
96c1c5a328 Use rusts internal hash algorithm. 2018-11-12 21:24:53 +01:00
Windel Bouwman
49f855219a Implement sys.getrefcount, sys.ps1, sys.ps2 and sys.getsizeof 2018-11-11 20:54:30 +01:00
Adam Kelly
9cba8d2c3a Avoid crash debug logging circular dictionaries. 2018-11-11 18:32:27 +00:00
Adam Kelly
84ef6e3053 Add Frame.f_code. 2018-11-11 18:12:30 +00:00
Adam Kelly
a1b7c61fcf Implement sys._getframe() to the point where we can use it to get locals. 2018-11-11 17:54:30 +00:00
Bojan
ccd1534f69 Merge branch 'master' into bojan/objobject-__and__-default 2018-11-07 22:34:44 +01:00
Bojan
e7cd83240c Changed to proper implementation in vm 2018-11-07 22:32:20 +01:00
Windel Bouwman
c4cbedae2f Extend min builtin function to support key and default. 2018-11-07 19:25:18 +01:00
Windel Bouwman
99af466a88 Move max function test cases to snippet dir. Implement key and default argument on max function. 2018-11-07 17:26:18 +01:00