forked from M-Labs/nac3
1
0
Fork 0

core: optics rename view() to focus()

This commit is contained in:
lyken 2024-07-14 13:55:26 +08:00
parent 259958aded
commit b4d5b2a41f
2 changed files with 9 additions and 9 deletions

View File

@ -88,13 +88,13 @@ fn build_error_ids<'ctx>(ctx: &CodeGenContext<'ctx, '_>) -> Address<'ctx, ErrorI
let get_string_id =
|string_id| llvm_i32.const_int(ctx.resolver.get_string_id(string_id) as u64, false);
error_ids.view(ctx, |fields| &fields.index_error).store(ctx, &get_string_id("0:IndexError"));
error_ids.view(ctx, |fields| &fields.value_error).store(ctx, &get_string_id("0:ValueError"));
error_ids.focus(ctx, |fields| &fields.index_error).store(ctx, &get_string_id("0:IndexError"));
error_ids.focus(ctx, |fields| &fields.value_error).store(ctx, &get_string_id("0:ValueError"));
error_ids
.view(ctx, |fields| &fields.assertion_error)
.focus(ctx, |fields| &fields.assertion_error)
.store(ctx, &get_string_id("0:AssertionError"));
error_ids
.view(ctx, |fields| &fields.runtime_error)
.focus(ctx, |fields| &fields.runtime_error)
.store(ctx, &get_string_id("0:RuntimeError"));
error_ids
@ -155,11 +155,11 @@ pub fn check_error_context<'ctx, G: CodeGenerator + ?Sized>(
let error_str_ptr = StrLens { size_type }.alloca(ctx, "error_str");
call_nac3_error_context_get_error_str(size_type, ctx, errctx_ptr, &error_str_ptr);
let error_id = errctx_ptr.view(ctx, |fields| &fields.error_id).load(ctx, "error_id");
let error_id = errctx_ptr.focus(ctx, |fields| &fields.error_id).load(ctx, "error_id");
let error_str = error_str_ptr.load(ctx, "error_str");
let param1 = errctx_ptr.view(ctx, |fields| &fields.param1).load(ctx, "param1");
let param2 = errctx_ptr.view(ctx, |fields| &fields.param2).load(ctx, "param2");
let param3 = errctx_ptr.view(ctx, |fields| &fields.param3).load(ctx, "param3");
let param1 = errctx_ptr.focus(ctx, |fields| &fields.param1).load(ctx, "param1");
let param2 = errctx_ptr.focus(ctx, |fields| &fields.param2).load(ctx, "param2");
let param3 = errctx_ptr.focus(ctx, |fields| &fields.param3).load(ctx, "param3");
ctx.make_assert_impl_by_id(
generator,
has_error,

View File

@ -334,7 +334,7 @@ impl<'ctx, T: StructureOptic<'ctx>> MemorySetter<'ctx> for T {
}
impl<'ctx, AddresseeOptic: StructureOptic<'ctx>> Address<'ctx, AddresseeOptic> {
pub fn view<GetFieldGepFn, FieldElementOptic: Optic<'ctx>>(
pub fn focus<GetFieldGepFn, FieldElementOptic: Optic<'ctx>>(
&self,
ctx: &CodeGenContext<'ctx, '_>,
get_field_gep_fn: GetFieldGepFn,