class Savi::Compiler::Namespace

Overview

The purpose of the Namespace pass is to determine which type names are visible from which source files, and to raise an appropriate error in the event that two types visible from the same source file have the same identifier.

This pass does not mutate the Program topology. This pass does not mutate the AST. This pass may raise a compilation error. This pass keeps state at the program level. This pass produces output state at the source package level.

Defined in:

savi/compiler/namespace.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def [](package : Program::Package::Link) : Analysis #

When given a package link, return the set of types accessible within it.


[View source]
def [](source_package : Source::Package) : Analysis #

When given a source package, return the set of types accessible within it.


[View source]
def []?(package : Program::Package::Link) : Analysis | Nil #

[View source]
def []?(source_package : Source::Package) : Analysis | Nil #

[View source]
def core_savi_package_link #

[View source]
def core_savi_type(ctx, name : String) : Program::Type::Link #

When given a String name, try to find the type in the core_savi package. This is a way to resolve a builtin type by name without more context.


[View source]
def find_func!(ctx, source, type_name, func_name) #

TODO Remove this method? This is only for use in testing.


[View source]
def main_type!(ctx) #

[View source]
def main_type?(ctx) : Program::Type::Link | Nil #

[View source]
def run(ctx) #

[View source]