| 1 | // Copyright (c) 2020-2024 Joe Conigliaro. All rights reserved. |
| 2 | // Use of this source code is governed by an MIT license |
| 3 | // that can be found in the LICENSE file. |
| 4 | module types |
| 5 | |
| 6 | pub struct Module { |
| 7 | pub: |
| 8 | name string |
| 9 | path string |
| 10 | imports []Module |
| 11 | scope &Scope = new_scope(unsafe { nil }) |
| 12 | } |
| 13 | |
| 14 | pub fn new_module(name string, path string) &Module { |
| 15 | return &Module{ |
| 16 | name: name |
| 17 | path: path |
| 18 | scope: new_scope(universe) |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | // lookup resolves a symbol from this module scope. |
| 23 | pub fn (m &Module) lookup(name string) ?Object { |
| 24 | mut scope := unsafe { m.scope } |
| 25 | return scope.lookup_parent(name, 0) |
| 26 | } |
| 27 | |