# Path: pycket/values.py
# class W_Symbol(W_Object):
#     errorname = "symbol"
#     _attrs_ = ["unreadable", "_isascii", "_unicodevalue", "utf8value", "bar_quoted"]
#     _immutable_fields_ = ["unreadable", "utf8value", "bar_quoted"]
# 
#     def __init__(self, val, unreadable=False):
#         assert isinstance(val, str)
#         self._unicodevalue = None
#         self.utf8value = val
#         self.unreadable = unreadable
#         self._isascii = MAYBE
#         self.bar_quoted = False
#         if val == "" or val == ".":
#             self.bar_quoted = True
#         else:
#             for q in " ()[]{}|\\,`'":
#                 if q in val:
#                     self.bar_quoted = True
#                     break
# 
#     def is_bar_quoted(self):
#         return self.bar_quoted
# 
#     def is_unreadable(self):
#         return self.unreadable
# 
#     @staticmethod
#     def _cache_is_ascii(self):
#         from pycket.values_string import _is_ascii
#         if not we_are_translated():
#             assert self._isascii == MAYBE
#         if _is_ascii(self.utf8value):
#             self._isascii = DEFINITELY_YES
#         else:
#             self._isascii = DEFINITELY_NO
#         return self._isascii
# 
#     def asciivalue(self):
#         isascii = jit.conditional_call_elidable(
#             self._isascii, W_Symbol._cache_is_ascii, self)
#         if isascii == DEFINITELY_NO:
#             return None
#         return self.utf8value
# 
#     @jit.elidable
#     def unicodevalue(self):
#         if self._unicodevalue is None:
#             self._unicodevalue = self.utf8value.decode("utf-8")
#         return self._unicodevalue
# 
#     @staticmethod
#     @jit.elidable
#     def make(string):
#         # This assert statement makes the lowering phase of rpython break...
#         # Maybe comment back in and check for bug.
#         assert isinstance(string, str)
#         w_result = W_Symbol.all_symbols.get(string, None)
#         if w_result is None:
#             w_result = W_Symbol(string)
#             W_Symbol.all_symbols[string] = w_result
#         return w_result
# 
#     @staticmethod
#     @jit.elidable
#     def make_unreadable(string):
#         w_result = W_Symbol.unreadable_symbols.get(string, None)
#         if w_result is None:
#             w_result = W_Symbol(string, unreadable=True)
#             W_Symbol.unreadable_symbols[string] = w_result
#         return w_result
# 
#     def __repr__(self):
#         return self.utf8value
# 
#     @jit.elidable
#     def is_interned(self):
#         if self.unreadable:
#             return False
#         string = self.utf8value
#         symbol = W_Symbol.all_symbols.get(string, None)
#         if symbol is self:
#             return True
#         return False
# 
#     def tostring(self):
#         return "%s" % self.utf8value
# 
#     def variable_name(self):
#         return self.utf8value


from pycket.values import W_Symbol
from pycket.prims.expose import define_nyi, prim_env, expose
    from pycket.prims.expose import prim_env
    from pycket.values import W_Symbol, W_Prim

pycket_extra_str = ["pycket:activate-debug", "pycket:deactivate-debug",
                    "pycket:get-verbosity", "pycket:set-verbosity",
                    "pycket:is-debug-active", "pycket:print",
                    "pycket:activate-keyword", "pycket:deactivate-keyword",
                    "pycket:eq?", "pycket:report-undefined-prims"]

schemify_hooks = ["variable-ref", "variable-ref/no-check",
                  "variable-set!/check-undefined", "variable-set!"]

# The reason for make_primitive_table is for turning these into list
# of symbols (to avoid making new objects everytime we look things up)

place = make_primitive_table(place_str)
paramz = make_primitive_table(paramz_str)
internal = make_primitive_table(internal_str)
futures = make_primitive_table(futures_str)
flfxnum = make_primitive_table(flfxnum_str)
extfl = make_primitive_table(extfl_str)
network = make_primitive_table(network_str)
foreign = make_primitive_table(foreign_str)
linklet = make_primitive_table(linklet_str)
unsafe = make_primitive_table(unsafe_str)
# FIXME : make it a #%pycket-extra, instead of piggybacking on the #%kernel
kernel = make_primitive_table(kernel_str)
pycket = make_primitive_table(pycket_extra_str + schemify_hooks)

select_prim_table = {W_Symbol.make("#%linklet"): linklet,
                     W_Symbol.make("#%kernel"): kernel,
                     W_Symbol.make("#%paramz"): paramz,

# Path: pycket/values.py
# class W_Symbol(W_Object):
#     errorname = "symbol"
#     _attrs_ = ["unreadable", "_isascii", "_unicodevalue", "utf8value", "bar_quoted"]
#     _immutable_fields_ = ["unreadable", "utf8value", "bar_quoted"]
# 
#     def __init__(self, val, unreadable=False):
#         assert isinstance(val, str)
#         self._unicodevalue = None
#         self.utf8value = val
#         self.unreadable = unreadable
#         self._isascii = MAYBE
#         self.bar_quoted = False
#         if val == "" or val == ".":
#             self.bar_quoted = True
#         else:
#             for q in " ()[]{}|\\,`'":
#                 if q in val:
#                     self.bar_quoted = True
#                     break
# 
#     def is_bar_quoted(self):
#         return self.bar_quoted
# 
#     def is_unreadable(self):
#         return self.unreadable
# 
#     @staticmethod
#     def _cache_is_ascii(self):
#         from pycket.values_string import _is_ascii
#         if not we_are_translated():
#             assert self._isascii == MAYBE
#         if _is_ascii(self.utf8value):
#             self._isascii = DEFINITELY_YES
#         else:
#             self._isascii = DEFINITELY_NO
#         return self._isascii
# 
#     def asciivalue(self):
#         isascii = jit.conditional_call_elidable(
#             self._isascii, W_Symbol._cache_is_ascii, self)
#         if isascii == DEFINITELY_NO:
#             return None
#         return self.utf8value
# 
#     @jit.elidable
#     def unicodevalue(self):
#         if self._unicodevalue is None:
#             self._unicodevalue = self.utf8value.decode("utf-8")
#         return self._unicodevalue
# 
#     @staticmethod
#     @jit.elidable
#     def make(string):
#         # This assert statement makes the lowering phase of rpython break...
#         # Maybe comment back in and check for bug.
#         assert isinstance(string, str)
#         w_result = W_Symbol.all_symbols.get(string, None)
#         if w_result is None:
#             w_result = W_Symbol(string)
#             W_Symbol.all_symbols[string] = w_result
#         return w_result
# 
#     @staticmethod
#     @jit.elidable
#     def make_unreadable(string):
#         w_result = W_Symbol.unreadable_symbols.get(string, None)
#         if w_result is None:
#             w_result = W_Symbol(string, unreadable=True)
#             W_Symbol.unreadable_symbols[string] = w_result
#         return w_result
# 
#     def __repr__(self):
#         return self.utf8value
# 
#     @jit.elidable
#     def is_interned(self):
#         if self.unreadable:
#             return False
#         string = self.utf8value
#         symbol = W_Symbol.all_symbols.get(string, None)
#         if symbol is self:
#             return True
#         return False
# 
#     def tostring(self):
#         return "%s" % self.utf8value
# 
#     def variable_name(self):
#         return self.utf8value


# Path: pycket/prims/primitive_tables.py
from pycket.values import W_Symbol
from pycket.prims.expose import define_nyi, prim_env, expose
    from pycket.prims.expose import prim_env
    from pycket.values import W_Symbol, W_Prim


pycket_extra_str = ["pycket:activate-debug", "pycket:deactivate-debug",
                    "pycket:get-verbosity", "pycket:set-verbosity",
                    "pycket:is-debug-active", "pycket:print",
                    "pycket:activate-keyword", "pycket:deactivate-keyword",
                    "pycket:eq?", "pycket:report-undefined-prims"]

schemify_hooks = ["variable-ref", "variable-ref/no-check",
                  "variable-set!/check-undefined", "variable-set!"]

# The reason for make_primitive_table is for turning these into list
# of symbols (to avoid making new objects everytime we look things up)

place = make_primitive_table(place_str)
paramz = make_primitive_table(paramz_str)
internal = make_primitive_table(internal_str)
futures = make_primitive_table(futures_str)
flfxnum = make_primitive_table(flfxnum_str)
extfl = make_primitive_table(extfl_str)
network = make_primitive_table(network_str)
foreign = make_primitive_table(foreign_str)
linklet = make_primitive_table(linklet_str)
unsafe = make_primitive_table(unsafe_str)
# FIXME : make it a #%pycket-extra, instead of piggybacking on the #%kernel
kernel = make_primitive_table(kernel_str)
pycket = make_primitive_table(pycket_extra_str + schemify_hooks)

select_prim_table = {W_Symbol.make("#%linklet"): linklet,
                     W_Symbol.make("#%kernel"): kernel,
                     W_Symbol.make("#%paramz"): paramz,

                     W_Symbol.make("#%unsafe"): unsafe,