feat(library/vm): add expr.copy_pos_info

This commit is contained in:
Leonardo de Moura 2016-11-10 11:50:38 -08:00
parent 83e0e7104c
commit a7af70da2e
2 changed files with 14 additions and 6 deletions

View file

@ -73,12 +73,14 @@ meta def expr.abstract : expr → expr → expr
meta constant expr.instantiate_var : expr → expr → expr
meta constant expr.instantiate_vars : expr → list expr → expr
meta constant expr.has_var : expr → bool
meta constant expr.has_var_idx : expr → nat → bool
meta constant expr.has_local : expr → bool
meta constant expr.has_meta_var : expr → bool
meta constant expr.lift_vars : expr → nat → nat → expr
meta constant expr.lower_vars : expr → nat → nat → expr
meta constant expr.has_var : expr → bool
meta constant expr.has_var_idx : expr → nat → bool
meta constant expr.has_local : expr → bool
meta constant expr.has_meta_var : expr → bool
meta constant expr.lift_vars : expr → nat → nat → expr
meta constant expr.lower_vars : expr → nat → nat → expr
/- (copy_pos_info src tgt) copy position information from src to tgt. -/
meta constant expr.copy_pos_info : expr → expr → expr
namespace expr
open decidable

View file

@ -13,6 +13,7 @@ Author: Leonardo de Moura
#include "kernel/for_each_fn.h"
#include "kernel/replace_fn.h"
#include "library/expr_lt.h"
#include "library/deep_copy.h"
#include "library/vm/vm.h"
#include "library/vm/vm_nat.h"
#include "library/vm/vm_string.h"
@ -313,6 +314,10 @@ vm_obj expr_hash(vm_obj const & e) {
return mk_vm_simple(r); // make sure it is a simple value
}
vm_obj expr_copy_pos_info(vm_obj const & src, vm_obj const & tgt) {
return to_obj(copy_tag(to_expr(src), copy(to_expr(tgt))));
}
void initialize_vm_expr() {
DECLARE_VM_BUILTIN(name({"expr", "var"}), expr_var);
DECLARE_VM_BUILTIN(name({"expr", "sort"}), expr_sort);
@ -344,6 +349,7 @@ void initialize_vm_expr() {
DECLARE_VM_BUILTIN(name({"expr", "lift_vars"}), expr_lift_vars);
DECLARE_VM_BUILTIN(name({"expr", "lower_vars"}), expr_lower_vars);
DECLARE_VM_BUILTIN(name({"expr", "hash"}), expr_hash);
DECLARE_VM_BUILTIN(name({"expr", "copy_pos_info"}), expr_copy_pos_info);
DECLARE_VM_CASES_BUILTIN(name({"expr", "cases_on"}), expr_cases_on);
}