2016-11-16 22:11:58 +01:00
|
|
|
// 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 {
|
2016-11-17 03:55:20 +01:00
|
|
|
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).
|
2016-11-16 22:11:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// SymbolKind indicates the kind of symbol being registered (e.g., Stack, Service, etc).
|
|
|
|
type SymbolKind int
|
|
|
|
|
|
|
|
const (
|
2016-11-17 03:55:20 +01:00
|
|
|
SymKindStack SymbolKind = iota
|
|
|
|
SymKindService
|
2016-11-16 22:11:58 +01:00
|
|
|
)
|
|
|
|
|
2016-11-17 03:55:20 +01:00
|
|
|
func NewStackSymbol(nm ast.Name, stack *ast.Stack) *Symbol {
|
|
|
|
return &Symbol{SymKindStack, nm, &stack.Node, stack}
|
|
|
|
}
|
|
|
|
|
2016-11-16 22:11:58 +01:00
|
|
|
func NewServiceSymbol(nm ast.Name, svc *ast.Service) *Symbol {
|
2016-11-17 03:55:20 +01:00
|
|
|
return &Symbol{SymKindService, nm, &svc.Node, svc}
|
2016-11-16 22:11:58 +01:00
|
|
|
}
|