Turn script_type_parser into a class (#18211)
authorMichael Suo <suo@fb.com>
Fri, 22 Mar 2019 23:24:36 +0000 (16:24 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 22 Mar 2019 23:30:05 +0000 (16:30 -0700)
commitff3ecfec893e31d8c1696f278d4c136536449a3b
tree82fde04f6e0a6746de9a66c914b1c85fdbb68a39
parent10751d5fb44f339ee96873cb8043d5393fd73f8f
Turn script_type_parser into a class (#18211)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18211
ghimport-source-id: 73b81e9ec631937b14db1da10991831788a6894b

Stack from [ghstack](https://github.com/ezyang/ghstack):
* #18296 [jit] Add namespacing for ScriptClasses
* #18284 [jit] make test module hook use save/load
* **#18211 [jit] Turn script_type_parser into a class**
* #18148 [jit] python interop for script classes

If we are namespacing classes, the type parser will need to carry around
some state about which namespaces to look in. This PR just wraps it in a
class in preparation.

Also, subscriptToType can no longer be static, since parseTypeFromExpr
may give different results depending on the namespaces available, so
it's been made a regular function instead of a static map lookup.

Reviewed By: eellison

Differential Revision: D14581128

fbshipit-source-id: 711315472ccde1920abf9fdb5a871ac27fb86787
torch/csrc/jit/import.cpp
torch/csrc/jit/script/compiler.cpp
torch/csrc/jit/script/script_type_parser.cpp
torch/csrc/jit/script/script_type_parser.h