1 #!/usr/bin/env python2
2 """func_init.py"""
3 from __future__ import print_function
4
5 from _devbuild.gen.id_kind_asdl import Id
6 from _devbuild.gen.runtime_asdl import value, scope_e
7 from core import vm
8 from frontend import lexer
9 from frontend import location
10
11 from typing import TYPE_CHECKING, Dict, List, Callable, Union, cast
12 if TYPE_CHECKING:
13 from core import state
14
15
16 def SetGlobalFunc(mem, name, func):
17 # type: (state.Mem, str, vm._Callable) -> None
18 assert isinstance(func, vm._Callable), func
19
20 # TODO: Fix this location info
21 #left = lexer.DummyToken(Id.Undefined_Tok, '')
22 mem.SetValue(location.LName(name), value.Func(func),
23 scope_e.GlobalOnly)