ident

package
v0.0.5-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ident provides a identifier creator which enforces unique variable names within the same scope

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gen

type Gen struct {
	LocalScopeMem   map[string]int
	GlobaleScopeMem map[string]int
}

Gen IGen implementation, responsible for generating unique variable names

func (*Gen) Create

func (g *Gen) Create(i *ast.Ident) *ast.Ident

Create creates a new local scope identifier

func (*Gen) CreateGlobal

func (g *Gen) CreateGlobal(i *ast.Ident) *ast.Ident

CreateGlobal creates new global scope identifier

func (*Gen) ResetLocal

func (g *Gen) ResetLocal()

ResetLocal resets the local scope memory

type IGen

type IGen interface {
	Create(i *ast.Ident) *ast.Ident
	CreateGlobal(i *ast.Ident) *ast.Ident
	ResetLocal()
}

IGen variable generator interface

func New

func New() IGen

New creates a new variable generator

func NewGenWithGlobal

func NewGenWithGlobal(global map[string]int) IGen

NewGenWithGlobal creates a new variable generator from a global map

func NewMock

func NewMock() IGen

NewMock creates new mock

type Mock

type Mock struct{}

Mock IGen mock

func (*Mock) Create

func (m *Mock) Create(i *ast.Ident) *ast.Ident

Create mocks local creation

func (*Mock) CreateGlobal

func (m *Mock) CreateGlobal(i *ast.Ident) *ast.Ident

CreateGlobal mocks global creation

func (*Mock) ResetLocal

func (m *Mock) ResetLocal()

ResetLocal reset local scope mock

Jump to

Keyboard shortcuts

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