def code_to_get_rest_args(operand_codes, pop_all_symbol): code_for_next_arg = preserving((argl_r,), operand_codes.car(), make_ir_seq((val_r, argl_r), (argl_r,), ir.cons(argl_r, val_r, argl_r)), pop_all_symbol) if operand_codes.cdr().nullp(): return code_for_next_arg return preserving((env_r,), code_for_next_arg, code_to_get_rest_args(operand_codes.cdr(), pop_all_symbol), pop_all_symbol)
def compile_literal(exp, target, linkage, cenv, pop_all_symbol): if exp is nil: return end_with_linkage(linkage, make_ir_seq((), (target,), mov(target, nil_r)), pop_all_symbol) return compile_self_evaluating(exp, target, linkage, cenv, pop_all_symbol) if self_evaluatingp(exp) or symbolp(exp): return compile_self_evaluating(exp, target, linkage, cenv, pop_all_symbol) if pairp(exp): reg = tmp_r if reg is target: reg = val_r # this feels like a hack d = compile_literal(exp.cdr(), target, next_s, cenv, pop_all_symbol) a = compile_literal(exp.car(), reg, next_s, cenv, pop_all_symbol) return end_with_linkage(linkage, append_ir_seqs( d, preserving((target,), a, make_ir_seq((reg, target), (target,), ir.cons(target, reg, target)), pop_all_symbol)), pop_all_symbol) raise CompileError(exp, "Can't compile literal")