hare

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

lookup.ha (530B)


      1 // License: MPL-2.0
      2 // (c) 2021 Drew DeVault <sir@cmpwn.com>
      3 // (c) 2021 Eyal Sawady <ecs@d2evs.net>
      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 })!;