sourcecode

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

This package defines source code entities - abstractions that end-user (a programmer) operates on. For convenience these structures have json tags. This is not clean architecture but it's very handy for LSP.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrModNotFound    = errors.New("module not found")
	ErrPkgNotFound    = fmt.Errorf("package not found")
	ErrImportNotFound = errors.New("import not found")
	ErrFileNotFound   = errors.New("file not found")
	ErrEntityNotPub   = errors.New("entity is not public")
)
View Source
var ErrEntityNotFound = errors.New("entity not found")

Functions

This section is empty.

Types

type ArrayBypassConnection

type ArrayBypassConnection struct {
	SenderOutport  PortAddr `json:"senderOutport,omitempty"`
	ReceiverInport PortAddr `json:"receiverOutport,omitempty"`
}

type Build

type Build struct {
	EntryModRef ModuleRef            `json:"entryModRef,omitempty"`
	Modules     map[ModuleRef]Module `json:"modules,omitempty"`
}

type Component

type Component struct {
	Directives map[Directive][]string `json:"directives,omitempty"`
	Interface  `json:"interface,omitempty"`
	Nodes      map[string]Node `json:"nodes,omitempty"`
	Net        []Connection    `json:"net,omitempty"`
	Meta       core.Meta       `json:"meta,omitempty"`
}

type Connection

type Connection struct {
	Normal      *NormalConnection      `json:"normal,omitempty"`
	ArrayBypass *ArrayBypassConnection `json:"arrayBypass,omitempty"`
	Meta        core.Meta              `json:"meta,omitempty"`
}

type ConnectionReceiver

type ConnectionReceiver struct {
	PortAddr  PortAddr                `json:"portAddr,omitempty"`
	Selectors ConnectionSideSelectors `json:"selectors,omitempty"`
	Meta      core.Meta               `json:"meta,omitempty"`
}

func (ConnectionReceiver) String

func (r ConnectionReceiver) String() string

type ConnectionReceiverSide

type ConnectionReceiverSide struct {
	DeferredConnections []Connection         `json:"deferredConnections,omitempty"`
	Receivers           []ConnectionReceiver `json:"receivers,omitempty"`
}

type ConnectionSenderSide

type ConnectionSenderSide struct {
	PortAddr  *PortAddr `json:"portAddr,omitempty"`
	Const     *Const    `json:"literal,omitempty"`
	Selectors []string  `json:"selectors,omitempty"`
	Meta      core.Meta `json:"meta,omitempty"`
}

ConnectionSenderSide unlike ReceiverConnectionSide could refer to constant.

func (ConnectionSenderSide) String

func (s ConnectionSenderSide) String() string

type ConnectionSideSelectors

type ConnectionSideSelectors []string

func (ConnectionSideSelectors) String

func (c ConnectionSideSelectors) String() string

type Const

type Const struct {
	Ref     *core.EntityRef `json:"ref,omitempty"`
	Message *Message        `json:"value,omitempty"`
	Meta    core.Meta       `json:"meta,omitempty"`
}

func (Const) String

func (c Const) String() string

type Directive

type Directive string

type Entity

type Entity struct {
	IsPublic  bool       `json:"exported,omitempty"`
	Kind      EntityKind `json:"kind,omitempty"`
	Const     Const      `json:"const,omitempty"`
	Type      ts.Def     `json:"type,omitempty"`
	Interface Interface  `json:"interface,omitempty"`
	Component Component  `json:"component,omitempty"`
}

func (Entity) Meta

func (e Entity) Meta() *core.Meta

type EntityKind

type EntityKind string // It's handy to transmit strings enum instead of digital
const (
	ComponentEntity EntityKind = "component_entity"
	ConstEntity     EntityKind = "const_entity"
	TypeEntity      EntityKind = "type_entity"
	InterfaceEntity EntityKind = "interface_entity"
)

type EnumMessage

type EnumMessage struct {
	EnumRef    core.EntityRef
	MemberName string
}

type File

type File struct {
	Imports  map[string]Import `json:"imports,omitempty"`
	Entities map[string]Entity `json:"entities,omitempty"`
}

type IO

type IO struct {
	In  map[string]Port `json:"in,omitempty"`
	Out map[string]Port `json:"out,omitempty"`
}

type Import

type Import struct {
	Module  string `json:"moduleName,omitempty"`
	Package string `json:"pkgName,omitempty"`
}

type Interface

type Interface struct {
	TypeParams TypeParams `json:"typeParams,omitempty"`
	IO         IO         `json:"io,omitempty,"`
	Meta       core.Meta  `json:"meta,omitempty"`
}

type Location

type Location struct {
	ModRef   ModuleRef
	PkgName  string
	FileName string
}

func (Location) String

func (l Location) String() string

type Message

type Message struct {
	TypeExpr    ts.Expr          `json:"typeExpr,omitempty"`
	Bool        *bool            `json:"bool,omitempty"`
	Int         *int             `json:"int,omitempty"`
	Float       *float64         `json:"float,omitempty"`
	Str         *string          `json:"str,omitempty"`
	List        []Const          `json:"vec,omitempty"`
	MapOrStruct map[string]Const `json:"map,omitempty"`
	Enum        *EnumMessage     `json:"enum,omitempty"`
	Meta        core.Meta        `json:"meta,omitempty"`
}

func (Message) String

func (m Message) String() string

type Module

type Module struct {
	Manifest ModuleManifest     `json:"manifest,omitempty"`
	Packages map[string]Package `json:"packages,omitempty"`
}

func (Module) Entity

func (mod Module) Entity(entityRef core.EntityRef) (entity Entity, filename string, err error)

func (Module) Files

func (mod Module) Files(f func(file File, pkgName, fileName string))

type ModuleManifest

type ModuleManifest struct {
	LanguageVersion string               `json:"neva,omitempty" yaml:"neva,omitempty"`
	Deps            map[string]ModuleRef `json:"deps,omitempty" yaml:"deps,omitempty"`
}

type ModuleRef

type ModuleRef struct {
	Path    string `json:"path,omitempty"`
	Version string `json:"version,omitempty"`
}

func (ModuleRef) String

func (m ModuleRef) String() string

type Node

type Node struct {
	Directives map[Directive][]string `json:"directives,omitempty"`
	EntityRef  core.EntityRef         `json:"entityRef,omitempty"`
	TypeArgs   TypeArgs               `json:"typeArgs,omitempty"`
	ErrGuard   bool                   `json:"errGuard,omitempty"`
	Deps       map[string]Node        `json:"componentDi,omitempty"`
	Meta       core.Meta              `json:"meta,omitempty"`
}

func (Node) String

func (n Node) String() string

type NormalConnection

type NormalConnection struct {
	SenderSide   ConnectionSenderSide   `json:"senderSide,omitempty"`
	ReceiverSide ConnectionReceiverSide `json:"receiverSide,omitempty"`
}

type Package

type Package map[string]File

func (Package) Entities

func (p Package) Entities(f func(entity Entity, entityName string, fileName string) error) error

func (Package) Entity

func (p Package) Entity(entityName string) (entity Entity, filename string, ok bool)

Just like program's Entity

type Port

type Port struct {
	TypeExpr ts.Expr   `json:"typeExpr,omitempty"`
	IsArray  bool      `json:"isArray,omitempty"`
	Meta     core.Meta `json:"meta,omitempty"`
}

type PortAddr

type PortAddr struct {
	Node string    `json:"node,omitempty"`
	Port string    `json:"port,omitempty"`
	Idx  *uint8    `json:"idx,omitempty"`
	Meta core.Meta `json:"meta,omitempty"`
}

func (PortAddr) String

func (p PortAddr) String() string

type Scope

type Scope struct {
	Location Location
	Build    Build
}

func (Scope) Entity

func (s Scope) Entity(entityRef core.EntityRef) (Entity, Location, error)

func (Scope) GetType

func (s Scope) GetType(ref core.EntityRef) (ts.Def, ts.Scope, error)

func (Scope) IsTopType

func (s Scope) IsTopType(expr ts.Expr) bool

func (Scope) WithLocation

func (s Scope) WithLocation(location Location) Scope

type TypeArgs

type TypeArgs []ts.Expr

func (TypeArgs) String

func (t TypeArgs) String() string

type TypeParams

type TypeParams struct {
	Params []ts.Param `json:"params,omitempty"`
	Meta   core.Meta  `json:"meta,omitempty"`
}

func (TypeParams) String

func (t TypeParams) String() string

func (TypeParams) ToFrame

func (t TypeParams) ToFrame() map[string]ts.Def

Directories

Path Synopsis
Package typesystem implements type-system with generics and structural subtyping.
Package typesystem implements type-system with generics and structural subtyping.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL