hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

lookup.ha (509B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 use hare::ast;
      5 
      6 // Unwraps a type which may be aliased and returns the underlying type.
      7 export fn dealias(t: *_type) const *_type = {
      8 	for (true) match (t.repr) {
      9 	case let a: alias =>
     10 		t = a.secondary as const *_type;
     11 	case =>
     12 		break;
     13 	};
     14 	return t;
     15 };
     16 
     17 // Looks up a built-in type.
     18 export fn lookup_builtin(
     19 	store: *typestore,
     20 	_type: ast::builtin_type,
     21 ) const *_type = lookup(store, &ast::_type {
     22 	repr = _type,
     23 	...
     24 })!;