class Savi::Compiler::Populate

Overview

The purpose of the Populate pass is to copy a set of functions from one type to another, such that any functions missing in the destination type will be copied from the source type. In the most common case, this is caused by an "is" annotation on a type denoting an inheritance relationship. The Populate pass also creates missing methods, like the default constructor.

This pass uses copy-on-mutate patterns to "mutate" the Program topology. This pass does not mutate ASTs, but copies whole functions to other types. This pass may raise a compilation error. This pass keeps temporary state (on the stack) at the per-type level. This pass produces no output state.

Defined in:

savi/compiler/populate.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def copy_from(ctx : Context, source : Program::Type, dest : Program::Type) #

For each concrete function in the given source, copy it to the destination if the destination doesn't already have an implementation for it. Don't actually copy yet - just return the new functions to be copied in.


[View source]
def gather_copy_sources(ctx, t : Program::Type, list = [] of ::Tuple(Program::Type, ReplaceIdentifiersVisitor | ::Nil), visitor_recursive : ReplaceIdentifiersVisitor | Nil = nil) #

[View source]
def run(ctx, package) #

[View source]