Unify implementations of eval-X-compile
This commit is contained in:
parent
49d2523e17
commit
52a0c8a870
@ -2081,22 +2081,15 @@ class HyASTCompiler(object):
|
|||||||
expr = tag_macroexpand(tag, expression.pop(0), self)
|
expr = tag_macroexpand(tag, expression.pop(0), self)
|
||||||
return self.compile(expr)
|
return self.compile(expr)
|
||||||
|
|
||||||
@builds("eval_and_compile")
|
@builds("eval_and_compile", "eval_when_compile")
|
||||||
def compile_eval_and_compile(self, expression):
|
def compile_eval_and_compile(self, expression, building):
|
||||||
expression[0] = HySymbol("do")
|
expression[0] = HySymbol("do")
|
||||||
hy.importer.hy_eval(expression,
|
hy.importer.hy_eval(expression,
|
||||||
compile_time_ns(self.module_name),
|
compile_time_ns(self.module_name),
|
||||||
self.module_name)
|
self.module_name)
|
||||||
expression.pop(0)
|
return (self._compile_branch(expression[1:])
|
||||||
return self._compile_branch(expression)
|
if building == "eval_and_compile"
|
||||||
|
else Result())
|
||||||
@builds("eval_when_compile")
|
|
||||||
def compile_eval_when_compile(self, expression):
|
|
||||||
expression[0] = HySymbol("do")
|
|
||||||
hy.importer.hy_eval(expression,
|
|
||||||
compile_time_ns(self.module_name),
|
|
||||||
self.module_name)
|
|
||||||
return Result()
|
|
||||||
|
|
||||||
@builds(HyCons)
|
@builds(HyCons)
|
||||||
def compile_cons(self, cons):
|
def compile_cons(self, cons):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user