Documentation ¶
Overview ¶
Package object how the interpretor holds objects during execution
Index ¶
- Constants
- func DecodeBytes(bts []byte) string
- type Array
- type Auto
- type BStr
- type Builtin
- type BuiltinFunction
- type Console
- type Environment
- func (e *Environment) AddCmdStmt(stmt ast.Statement)
- func (e *Environment) AddOpenFile(num int16, file gwtypes.AnOpenFile)
- func (e *Environment) AddStatement(stmt ast.Statement)
- func (e *Environment) ClearCommon()
- func (e *Environment) ClearVars()
- func (e *Environment) CloseAllFiles()
- func (e *Environment) CloseFile(f int16) bool
- func (e *Environment) ClrSetting(name string)
- func (e *Environment) CmdComplete()
- func (e *Environment) CmdLineIter() *ast.Code
- func (e *Environment) CmdParsed()
- func (e *Environment) Common(name string)
- func (e *Environment) ConstData() *ast.ConstData
- func (e *Environment) FindOpenFiles(file string) []gwtypes.AnOpenFile
- func (e *Environment) Get(name string) Object
- func (e *Environment) GetClient() HttpClient
- func (e *Environment) GetSetting(name string) ast.Node
- func (e *Environment) GetTrace() bool
- func (e *Environment) NewProgram()
- func (e *Environment) Parsed()
- func (e *Environment) Pop() *ast.RetPoint
- func (e *Environment) ProgramRunning() bool
- func (e *Environment) Push(ret ast.RetPoint) int
- func (e *Environment) Random(x int) *FloatSgl
- func (e *Environment) Randomize(seed int64)
- func (e *Environment) ReadOnly(v string) bool
- func (e *Environment) SaveSetting(name string, obj ast.Node)
- func (e *Environment) Set(name string, val Object) Object
- func (e *Environment) SetClient(cl HttpClient)
- func (e *Environment) SetRun(run bool)
- func (e *Environment) SetTrace(on bool)
- func (e *Environment) StatementIter() *ast.Code
- func (e *Environment) Terminal() Console
- type Error
- type Fixed
- type FloatDbl
- type FloatSgl
- type ForBlock
- type Function
- type HaltSignal
- type HttpClient
- type IntDbl
- type Integer
- type Null
- type Object
- type ObjectType
- type RestartSignal
- type String
- type TypedVar
Constants ¶
const ( GWBlack = iota // 0 GWBlue // 1 GWGreen // 2 GWCyan // 3 GWRed // 4 GWMagenta // 5 GWBrown // 6 GWWhite // 7 GWGray // 8 GWLtBlue // 9 GWLtGreen // 10 GWLtCyan // 11 GWLtRed // 12 GWLtMagenta // 13 GWYellow // 14 GWBrtWhite // 15 )
GWBasic color values for screen work,https://hwiegman.home.xs4all.nl/gw-man/SCREENS.html
const ( // XBlack = iota + 90 // 90 XRed = iota + 91 // 91 XGreen // 92 XYellow // 93 XBlue // 94 XMagenta // 95 XCyan // 96 XWhite // 97 XBlack = 30 )
XTerm.js color directives,https://xtermjs.org/docs/api/vtfeatures/
const ( ESC = "\x1B" CSI = ESC + "[" OSC = ESC + "]" SGRReset = CSI + "0m" // Select Graphic Rendition, reset // Screen colors SgrFgrBlack = CSI + "30m" // set foreground color to black SgrFgrRed = CSI + "31m" // set foreground color to red SgrFgrGreen = CSI + "32m" // set green SgrFgrYellow = CSI + "33m" // set yellow SgrFgrBlue = CSI + "34m" SgrFgrMagenta = CSI + "35m" SgrFgrCyan = CSI + "36m" SgrFgrWhite = CSI + "37m" SgrFgrBrown = CSI + "38;2;150;75;0m" SgrBgrBlack = CSI + "40m" // set background color to black SgrBgrRed = CSI + "41m" SgrBgrGreen = CSI + "42m" SgrBgrYellow = CSI + "43m" SgrBgrBlue = CSI + "44m" SgrBgrMagenta = CSI + "45m" SgrBgrCyan = CSI + "46m" SgrBgrWhite = CSI + "47m" SgrBgrBrown = CSI + "48;2;150;75;0m" // the bright colors SgrFgrBrtBlack = CSI + "90m" // set foreground color to bright black (grey) SgrFgrBrtRed = CSI + "91m" // set foreground color to bright red SgrFgrBrtGreen = CSI + "92m" SgrFgrBrtYellow = CSI + "93m" SgrFgrBrtBlue = CSI + "94m" SgrFgrBrtMagenta = CSI + "95m" SgrFgrBrtCyan = CSI + "96m" SgrFgrBrtWhite = CSI + "97m" SgrBgrBrtBlack = CSI + "100m" // set background color to bright black (grey) SgrBgrBrtRed = CSI + "101m" SgrBgrBrtGreen = CSI + "102m" SgrBgrBrtYellow = CSI + "103m" SgrBgrBrtBlue = CSI + "104m" SgrBgrBrtMagenta = CSI + "105m" SgrBgrBrtCyan = CSI + "106m" SgrBgrBrtWhite = CSI + "107m" )
const ( ARRAY_OBJ = "ARRAY" AUTO_OBJ = "AUTO" BSTR_OBJ = "BSTR" BUILTIN_OBJ = "BUILTIN" FILE_OBJ = "FILE" FIXED_OBJ = "FIXED" FLOATSGL_OBJ = "FLOATSGL" FLOATDBL_OBJ = "FLOATDBL" FUNCTION_OBJ = "FUNCTION" ERROR_OBJ = "ERROR" HALT_SIGNAL = "HALT" INTEGER_OBJ = "INTEGER" INTEGER_DBL = "INTDBL" NULL_OBJ = "NULL" RESTART_SIGNAL = "RESTART" STRING_OBJ = "STRING" TYPED_OBJ = "TYPED" )
const DefaultDimSize = 10
size of arrays that haven't been DIM'd
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Auto ¶
type Auto struct { Next int // the next line number to use Step int // the step to add to next each time }
When auto is on, this holds the current state
func (*Auto) Type ¶
func (a *Auto) Type() ObjectType
type BStr ¶
type BStr struct {
Value []byte
}
BStr is a byte backed string not COMmonly used parser won't generate one they only occur at run-time
type Builtin ¶
type Builtin struct {
Fn BuiltinFunction
}
func (*Builtin) Type ¶
func (b *Builtin) Type() ObjectType
type BuiltinFunction ¶
type BuiltinFunction func(env *Environment, fn *Builtin, args ...Object) Object
BuiltinFunction is a function defined by gwbasic
type Console ¶
type Console interface { // Cls clears the screen contents Cls() // Print outputs the passed string at the curent cursor position Print(string) // Println prints the string followed by a CR/LF Println(string) // Locate moves the cursor to the desired (row, col) Locate(int, int) // Log string to browser debug console Log(string) // GetCursor, return cursor location(row, col) GetCursor() (int, int) // Read, return contents of screen range Read(col, row, len int) string // ReadKeys reads up to (count) keycode values ReadKeys(count int) []byte // SoundBell emits facsimile of a console beep SoundBell() // BreakCheck returns true if a ctrl-c was entere BreakCheck() bool }
Console defines how to collect input and display output
type Environment ¶
type Environment struct { ForLoops []ForBlock // any For Loops that are active // contains filtered or unexported fields }
Environment holds my variables and possibly an outer environment
func NewEnclosedEnvironment ¶
func NewEnclosedEnvironment(outer *Environment) *Environment
NewEnclosedEnvironment allows variables during function calls
func NewTermEnvironment ¶
func NewTermEnvironment(term Console) *Environment
NewTermEnvironment creates an environment with a terminal front-end
func (*Environment) AddCmdStmt ¶
func (e *Environment) AddCmdStmt(stmt ast.Statement)
func (*Environment) AddOpenFile ¶
func (e *Environment) AddOpenFile(num int16, file gwtypes.AnOpenFile)
func (*Environment) AddStatement ¶
func (e *Environment) AddStatement(stmt ast.Statement)
Add a statement to the ast
func (*Environment) ClearVars ¶
func (e *Environment) ClearVars()
ClearVars empties the map of environment objects
func (*Environment) CloseAllFiles ¶
func (e *Environment) CloseAllFiles()
CloseAllFiles closes all open files
func (*Environment) CloseFile ¶
func (e *Environment) CloseFile(f int16) bool
CloseFile closes a file based on its handle
func (*Environment) CmdComplete ¶
func (e *Environment) CmdComplete()
func (*Environment) CmdLineIter ¶
func (e *Environment) CmdLineIter() *ast.Code
func (*Environment) Common ¶
func (e *Environment) Common(name string)
preserve a variable across a chain
func (*Environment) ConstData ¶
func (e *Environment) ConstData() *ast.ConstData
return the programs constant data
func (*Environment) FindOpenFiles ¶
func (e *Environment) FindOpenFiles(file string) []gwtypes.AnOpenFile
find all the currently open instances of files that match the fully qualified file name provided
func (*Environment) Get ¶
func (e *Environment) Get(name string) Object
Get attempts to retrieve an object from the environment, nil if not found
func (*Environment) GetClient ¶
func (e *Environment) GetClient() HttpClient
GetClient returns my http client
func (*Environment) GetSetting ¶
func (e *Environment) GetSetting(name string) ast.Node
Fetch a runtime setting
func (*Environment) GetTrace ¶
func (e *Environment) GetTrace() bool
GetTrace returns true if we are tracing
func (*Environment) NewProgram ¶
func (e *Environment) NewProgram()
NewProgram makes sure the program has been initialized
func (*Environment) Parsed ¶
func (e *Environment) Parsed()
Signals that the program has been parsed
func (*Environment) Pop ¶
func (e *Environment) Pop() *ast.RetPoint
Pop a return address, nil means stack is empty
func (*Environment) ProgramRunning ¶
func (e *Environment) ProgramRunning() bool
Quick test to see if program is currently running
func (*Environment) Push ¶
func (e *Environment) Push(ret ast.RetPoint) int
Push an address, returns stack size
func (*Environment) Random ¶
func (e *Environment) Random(x int) *FloatSgl
Random returns a random number between 0 and 1 if x is greater than zero, a new random number is generated otherwise, the current rndVal is returned
func (*Environment) Randomize ¶
func (e *Environment) Randomize(seed int64)
Randomize takes in a new seed and starts a new random series
func (*Environment) ReadOnly ¶
func (e *Environment) ReadOnly(v string) bool
check if a variable name is defined read only
func (*Environment) SaveSetting ¶
func (e *Environment) SaveSetting(name string, obj ast.Node)
Save a runtime setting
func (*Environment) Set ¶
func (e *Environment) Set(name string, val Object) Object
Set stores an object in the environment
func (*Environment) SetClient ¶
func (e *Environment) SetClient(cl HttpClient)
SetClient setter for the client element mostly used for testing
func (*Environment) SetRun ¶
func (e *Environment) SetRun(run bool)
SetRun controls the "a program is running"
func (*Environment) StatementIter ¶
func (e *Environment) StatementIter() *ast.Code
func (*Environment) Terminal ¶
func (e *Environment) Terminal() Console
Terminal allows access to the termianl console
type Error ¶
func StdError ¶
func StdError(env *Environment, err int) *Error
StdError returns both the GWBASIC message, and error code for a basic error
func (*Error) Type ¶
func (e *Error) Type() ObjectType
type FloatDbl ¶
type FloatDbl struct {
Value float64
}
Double precision floats
func (*FloatDbl) Type ¶
func (fd *FloatDbl) Type() ObjectType
type FloatSgl ¶
type FloatSgl struct {
Value float32 // value of the float
}
Single precision floats
func (*FloatSgl) Type ¶
func (fs *FloatSgl) Type() ObjectType
type ForBlock ¶
type ForBlock struct { Code ast.RetPoint // the location in the AST of the FOR statement Four *ast.ForStatement // the actual statement }
type Function ¶
type Function struct { Parameters []*ast.Identifier Body *ast.BlockStatement Env *Environment }
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type HaltSignal ¶
type HaltSignal struct {
Msg string
}
HaltSignal tells the eval loop to stop executing
func (*HaltSignal) Inspect ¶
func (hs *HaltSignal) Inspect() string
func (*HaltSignal) Type ¶
func (hs *HaltSignal) Type() ObjectType
type HttpClient ¶
type HttpClient interface { //Do(req *http.Request) (*http.Response, error) Get(url string) (*http.Response, error) }
HttpClient allows me to mock an http.Client, minimally
type Object ¶
type Object interface { Type() ObjectType Inspect() string }
type RestartSignal ¶
type RestartSignal struct{}
RestartSignal restarts the eval loop after a chain
func (*RestartSignal) Inspect ¶
func (rs *RestartSignal) Inspect() string
func (*RestartSignal) Type ¶
func (rs *RestartSignal) Type() ObjectType