This change adds rudimentary type binding to phase 2 of the binder. Note that we still don't have the notion of predefined types (for the primitives), so this basically rejects any well-formed Mufile. Primitives are on deck.
31 lines
847 B
Go
31 lines
847 B
Go
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
|
|
|
package compiler
|
|
|
|
import (
|
|
"github.com/marapongo/mu/pkg/ast"
|
|
)
|
|
|
|
// Symbol is a named entity that can be referenced and bound to.
|
|
type Symbol struct {
|
|
Kind SymbolKind // the kind of symbol.
|
|
Name ast.Name // the symbol's unique name.
|
|
Node *ast.Node // the Node part of the payload data structure.
|
|
Real interface{} // the real part of the payload (i.e., the whole structure).
|
|
}
|
|
|
|
// SymbolKind indicates the kind of symbol being registered (e.g., Stack, Service, etc).
|
|
type SymbolKind int
|
|
|
|
const (
|
|
SymKindStack SymbolKind = iota
|
|
SymKindService
|
|
)
|
|
|
|
func NewStackSymbol(nm ast.Name, stack *ast.Stack) *Symbol {
|
|
return &Symbol{SymKindStack, nm, &stack.Node, stack}
|
|
}
|
|
|
|
func NewServiceSymbol(nm ast.Name, svc *ast.Service) *Symbol {
|
|
return &Symbol{SymKindService, nm, &svc.Node, svc}
|
|
}
|