context.ha (658B)
1 // SPDX-License-Identifier: GPL-3.0-only 2 // (c) Hare authors <https://harelang.org> 3 4 use hare::types; 5 use hare::unit; 6 use io; 7 use memio; 8 9 type context = struct { 10 out: io::handle, 11 buf: memio::stream, 12 store: *types::typestore, 13 unit: *unit::unit, 14 arch: struct { 15 ptr: *qtype, 16 sz: *qtype, 17 }, 18 serial: uint, 19 bindings: []binding, 20 }; 21 22 type binding = struct { 23 object: *unit::object, 24 name: temporary, 25 }; 26 27 fn binding_lookup(ctx: *context, object: *unit::object) *binding = { 28 // XXX: We could use a hash map here 29 for (let i = 0z; i < len(ctx.bindings); i += 1) { 30 if (ctx.bindings[i].object == object) { 31 return &ctx.bindings[i]; 32 }; 33 }; 34 abort(); 35 };