Skip to content

Commit d760889

Browse files
committed
https://github.com/mathics/Mathics/pull/1160#pullrequestreview-594830742
1 parent aecf355 commit d760889

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

mathics/builtin/compilation.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from mathics.builtin.base import Builtin, BoxConstruct
44
from mathics.core.expression import Atom, Expression, Symbol, String, from_python, Integer, Real
55
from mathics.core.evaluation import Evaluation
6-
6+
from types import FunctionType
7+
78
class Compile(Builtin):
89
'''
910
<dl>
@@ -142,6 +143,8 @@ def __init__(self, cfunc, args, **kwargs):
142143
self.args = args
143144

144145
def __str__(self):
146+
if type(self.cfunc) is FunctionType:
147+
return '-PythonizedCode-'
145148
return '-CompiledCode-'
146149

147150
def do_copy(self):
@@ -166,21 +169,21 @@ def __hash__(self):
166169
return hash(("CompiledCode", ctypes.addressof(self.cfunc))) # XXX hack
167170

168171
def atom_to_boxes(self, f, evaluation):
169-
return Expression('CompiledCodeBox')
172+
return Expression('CompiledCodeBox', self)
170173

171174

172175
class CompiledCodeBox(BoxConstruct):
173176
"""
174177
Used internally by <i>CompileCode[]</i>.
175178
"""
176179
def boxes_to_text(self, leaves, **options):
177-
return '-CompiledCode-'
180+
return leaves[0].__str__()
178181

179182
def boxes_to_xml(self, leaves, **options):
180-
return '-CompiledCode-'
183+
return leaves[0].__str__()
181184

182185
def boxes_to_tex(self, leaves, **options):
183-
return '-CompiledCode-'
186+
return leaves[0].__str__()
184187

185188

186189
class CompiledFunction(Builtin):

0 commit comments

Comments
 (0)