Skip to content

Commit

Permalink
This is ridiculous. My git discipline is too lax. Oh well, it is what…
Browse files Browse the repository at this point in the history
… it is, I guess. Committing everything.
  • Loading branch information
acbart committed Aug 6, 2020
1 parent dbe45d2 commit 2026d37
Show file tree
Hide file tree
Showing 358 changed files with 36,459 additions and 20,998 deletions.
518 changes: 372 additions & 146 deletions HACKING.md

Large diffs are not rendered by default.

153 changes: 153 additions & 0 deletions breakingchanges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
**breaking changes**

**python 2 incorrectness:**
- `long`
- when adding two long objects the result is likely to be an `int`
- `method`
- unbound methods are no longer supported
- The `base` class for all type objects will be `object` even if the base class is not specified


**skulpt api**
- `Sk.builtin.object.prototype.genericGetAttr` -> `Sk.generic.getAttr`
- `Sk.builtin.object.prototype.genericSetAttr` -> `Sk.generic.setAttr`
- `Sk.builtin.typeLookup` removed
- `biginter.js` replaced by the [jsbi](https://github.com/GoogleChromeLabs/jsbi) library
- `Sk.abstr.inherits` removed - inheritance exclusively dealt with by `Sk.abstr.setUpInheritance`
- `Sk.misceval.objectRepr` returns a js string (previously `Sk.builtin.str`)
- `Sk.__future__.python3` becomes the default. Those wishing to use `python2` must define this in the `Sk.configure` object.

**slot changes**
- `mp$length` replaced by `sq$length` in the codebase
- `sq$ass_item`/`sq$ass_slice` replaced with `mp$ass_subscript`
- `nb$nonzero` replaced with `nb$bool` and switch version takes care of mapping the appropriate dunder method.
- `mp$del_subscript` replaced by `mp$ass_subscript` (as per Cpython)
- deleting vs setting an item is based on the call signature
- `mp$ass_subscript(key, value)` -> set item
- `mp$ass_subscript(key)` -> delete item
- If a dunder func is defined on a user defined class then the slot function is guaranteed.
- e.g. `__len__` defined guarantees `sq$length`.
- A slot function defined by skulpt in this way throws the appropriate errors and converts the return value to the appropriate object.
- `sq$length`: `__len__` is called using `Sk.misceval.callsim(OrSuspend)Array`.
- The result is checked to be an `int` and then converted to `number` since `sq$length` expects a `number`.
- `tp$str` removed from some builtins as per Python 3.8 changes
- If `tp$richcompare` is defined - wrapper functions `ob$eq` etc are created during - this way `Sk.misceval.richCompareBool` need only check for the existance of an `ob$*` slot.
- in fact - the existance of these slots is guaranteed since they are inherited from `Sk.builtin.object`
- `tp$mro`/`tp$bases` are Js Arrays rather than `Sk.builtin.tuple`
- `tp$str` and `$r` for errors were changed as per Cpython.

**flags**
- `sk$acceptable_as_base_class` used for some type objects
- `sk$object` every skulpt object inherits this flag from `Sk.builtin.object`
- `hp$type` all instance of `sk$klass` klasses
- `sk$basetype` all native classes that inherit from `object`
- `sk$prototypical` do we need to walk up the MRO or can we just check the `prototype`

**other internal changes**
- the use of `numPromoteFunc` was removed for performance improvements in the implementation of `Sk.asbtr.numberBinOp`
- It was performance beneficial to leave the promoting to the respective `nb$` slots
- `int` binop slots only deal with instance of `int`
- `float` binop slots deal with instances of `float` and `int`
- `complex` binop slots deal with instances of `complex`, `float` and `int`
- `set` and `frozenset` now share much of their implementation
- `collections` module rewritten using new api
- `itertools` module rewritten using new api - these are now type objects rather than instances of `generator`
- `dict` and `set` throw errors if the objects change size during iteration as per Cpython.
- `Sk.builtin.check*` moved to `src/check.js`
- `enumerate`/`filter_`/`reversed`/`zip_`/`map_` combined into one file `src/iteratorobjects.js`
- `tuple_iter_`/`str_iter_` etc combined into `src/simple_iterators.js`
- `dictviews` like `dict_items` etc moved to `src/dictviews.js`
- `number.js` removed
- `numtype.js` removed
- `seqtype.js` removed
- `Sk.builtin.check*` moved to `src/check.js`
- `mp$subscript` should not be called by a js object (see changes in `random.js`)


**call signatures of builtins**
- `new` is required for (almost) all builtin types
- 3 exceptions - `Sk.builtin.bool`, `Sk.builtin.none`, `Sk.builtin.NotImplemented`
- These 3 will always return their respective constant(s) and are thus not required to be used as constructors.
- Restricted parameters for directly accessing a constructor of an `Sk.builtin` type



| type | params | notes |
|---|---|---|
| `Sk.builtin.int_` | `{number| JSBI (bigint)| string| undefined}` | |
| `Sk.builtin.float_` | `{number}` | |
| `Sk.builtin.complex` | `{number, number}` | |
| `Sk.builtin.list` | `{Array=}` | |
| `Sk.builtin.tuple` | `{Array=}` | |
| `Sk.builtin.set` | `{Array=}` | |
| `Sk.builtin.dict` | `{Array=}` | key/value pairs - only pyObjects |
| `Sk.builtin.str` | `{*}` | can be used to convert a pyObject|
| `Sk.builtin.bool` | `{*}` | can be used to convert a pyObject|


**Major changes**
- All type objects are now callable using their respective `tp$call` methods inherited from `Sk.builtin.type`
- All native type objects will require a `tp$new` and `tp$init` method (maybe inherited by `Sk.builtin.object`)
- All type objects are javascript instances of `Sk.builtin.type`
- All single inherited objects follow javascript inheritance
- All native type objects now have the following and replaces the use of `Sk.builtin.function` for all dunder function/methods.
- `wrapper_descriptors` aka `slot_wrappers`
- `method_descriptors`
- `classmethod_descriptors`
- `getset_descriptors` aka `attributes`/`member_descriptors`
- `Sk.builtin.sk_method` is an alternative to `Sk.builtin.function` and is used by the above `descriptor` types
- mangled names are never passed to the user but instead are an attribute on `Sk.builtin.str` instances as `$mangled`
- `mappingproxy` added
- `$d` removed on all type objects.
- `attributes` of a type object now only appear on the `prototype`. Previously these appeared on both the `type` object and the `prototype`



**Additions**
- `dict`, `tuple` are suspendable
- `classmethod`, `property`, `staticmethod` have native skulpt implementations
- `super` can now be unbound
- `Sk.builtin.func` objects gain a `qualname` in compile code
- API for building native types
- `Sk.abstr.buildNativeClass`
- `range_iterator` class added
- `reverse` iterators added for `list`, `dict_views`, `range`
- `sk$asarray` used by types to convert to a javascript array.


**`Sk.abstr.`**
- `buildNativeClass`
- `buildIteratorClass`
- `setUpBuiltinMro`
- `setUpMethods`
- `setUpGetSets`
- `setUpSlots`
- `setUpClassMethod`
- `setUpBaseInheritance`
- `setUpModuleMethod`
- `checkNoKwargs`
- `checkNoArgs`
- `checkOneArg`
- `checkArgsLen`
- `copyKeywordsToNamedArgs`


**`Sk.generic.`**
- `getAttr`
- `setAttr`
- `selfIter`
- `iterator`
- `new`
- `newMethodDef`
- `iterNextWithArray`
- `iterNextWithArrayCheckSize`
- `iterLengthHintWithArrayMethodDef`
- `iterReverseLengthHintMethodDef`
- `getSetDict`

**`Sk.misceval.`**
- `asIndexOrThrow`
- `arrayFromIterable` - optional canSuspend implementation that returns an array from a python iterator

**`slotdefs.js`**
- contains all the information about mapping slots to dunders and vice versa.
8 changes: 4 additions & 4 deletions doc/ReferenceManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ Misc
Slot("__new__", "tp$new", "new"),
Slot("__init__", "tp$init", "init"),
Slot("__str__", "tp$print", "print"),
Slot("__repr__", "tp$repr", "repr",
Slot("__repr__", "$r", "repr",
opcode="UNARY_CONVERT"),
Slot("__hash__", "tp$hash", "hash"),
Expand Down Expand Up @@ -244,13 +244,13 @@ Misc
opcode="UNARY_NEGATIVE"),
Slot("__pos__", "nb$positive", "unary",
opcode="UNARY_POSITIVE"),
Slot("__abs__", "nb$absolute", "unary"),
Slot("__nonzero__", "nb$nonzero", "inquiry"), # inverse of UNARY_NOT opcode
Slot("__abs__", "nb$abs", "unary"),
Slot("__nonzero__", "nb$bool", "inquiry"), # inverse of UNARY_NOT opcode
Slot("__invert__", "nb$invert", "unary",
opcode="UNARY_INVERT"),
Slot("__coerce__", "nb$coerce", "coercion"), # not needed
Slot("__int__", "nb$int", "unary"), # expects exact int as return
Slot("__long__", "nb$long", "unary"), # expects exact long as return
Slot("__long__", "nb$lng", "unary"), # expects exact long as return
Slot("__float__", "nb$float", "unary"), # expects exact float as return
Slot("__oct__", "nb$oct", "unary"),
Slot("__hex__", "nb$hex", "unary"),
Expand Down
39 changes: 34 additions & 5 deletions jsdoc.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
{
"tags": {
"allowUnknownTags": true,
"dictionaries": ["jsdoc","closure"]
"dictionaries": ["jsdoc", "closure"]
},
"source": {
"include": ["src/misceval.js", "src/abstract.js", "src/function.js", "src/ffi.js", "src/import.js",
"src/int.js", "src/float.js", "src/bool.js", "src/constants.js", "src/object.js", "src/seqtype.js", "src/numtype.js"]
"include": [
"src/generic.js",
"src/misceval.js",
"src/abstract.js",
"src/ffi.js",
"src/slotdefs.js",
"src/import.js",
"src/function.js",
"src/complex.js",
"src/check.js",
"src/type.js",
"src/int.js",
"src/set.js",
"src/str.js",
"src/dict.js",
"src/tuple.js",
"src/iteratorobjects.js",
"src/simple_iterators.js",
"src/slice.js",
"src/float.js",
"src/range.js",
"src/bool.js",
"src/constants.js",
"src/object.js"
]
},
"plugins": ["plugins/markdown"],
"markdown": {
"hardwrap": true
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false
"monospaceLinks": false,
"default": {
"useLongnameInNav": true
}
},
"opts": {
"encoding": "utf8", // same as -e utf8
"destination": "./doc/ProgMan" // same as -d ./out/
}
}
}
37 changes: 20 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"watch": "webpack --watch --mode development",
"test": "node test/testwrapper.js && node test/testunit.js --python3",
"start": "node support/run/runfile.js",
"precompile": "node support/precompile/precompile.js",
"profile": "node --prof --no-logfile-per-isolate --log-internal-timer-events support/run/runfile.js -o",
"postprofile": "node --prof-process v8.log",
"standaloneparser": "webpack src/standalone_parser.js -o dist/python_parser.js"
Expand All @@ -44,33 +45,35 @@
"license": "MIT",
"private": true,
"devDependencies": {
"acorn": "^6.1.1",
"babel-minify": "^0.5.0",
"acorn": "^6.4.1",
"babel-minify": "^0.5.1",
"chalk": "^2.4.2",
"clean-webpack-plugin": "^2.0.2",
"closure-webpack-plugin": "^2.0.1",
"commander": "^2.20.0",
"closure-webpack-plugin": "^2.3.0",
"commander": "^2.20.3",
"compression-webpack-plugin": "^2.0.0",
"copy-webpack-plugin": "^5.0.3",
"ejs": "^2.6.1",
"copy-webpack-plugin": "^5.1.1",
"ejs": "^2.7.4",
"eslint": "^5.16.0",
"eslint-loader": "^2.1.2",
"eslint-loader": "^2.2.1",
"express": "^4.17.0",
"git-revision-webpack-plugin": "^3.0.3",
"git-revision-webpack-plugin": "^3.0.6",
"google-closure-compiler": "^20190415.0.0",
"js-beautify": "^1.10.0",
"jsdoc": "~3.5.5",
"js-beautify": "^1.11.0",
"jsdoc": "^3.6.3",
"micro-strptime": "^0.2.3",
"open": "^6.3.0",
"readline-sync": "^1.4.9",
"open": "^6.4.0",
"readline-sync": "^1.4.10",
"setimmediate": "^1.0.5",
"shelljs": "^0.8.3",
"shelljs": "^0.8.4",
"strftime": "^0.10.0",
"webpack": "^4.35.2",
"webpack-cli": "^3.3.5"
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12"
},
"engines": {
"node": ">=8.10"
"node": ">=10.4"
},
"dependencies": {}
"dependencies": {
"jsbi": "^3.1.3"
}
}
Loading

0 comments on commit 2026d37

Please sign in to comment.