class Savi::Compiler::Paint

Overview

The purpose of the Paint pass is to pick a "color" for each function in the program, such that functions which have the same name are guaranteed to have the same color but no two functions in a single type have the same color. The color id is then used to generate virtual-table call indexes, such that calling a function on a trait (with a specific color) will result in the function of the same name on the underlying concrete type being called (because it has the same color). In the future, this pass may need to become more sophisticated, perhaps to deal with multiple-dispatch forms.

This pass does not mutate the Program topology. This pass does not mutate the AST. This pass does not raise any compilation errors. This pass keeps state at the program level. This pass produces output state at the per-function level.

Defined in:

savi/compiler/paint.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def [](ctx, reach_func, for_continue = false) : Color #

Public: return the color id for the given function, assuming that this pass has already been run on the program.


[View source]
def []?(ctx, reach_func : Reach::Func, for_continue : Bool = false) : Color | Nil #

[View source]
def run(ctx) #

[View source]