Documentation ¶
Index ¶
- Constants
- Variables
- func PrintError(v *VM)
- type ArrayObject
- type BlockObject
- type BooleanObject
- type BuiltinMethodObject
- type ChannelObject
- type ConcurrentArrayObject
- type ConcurrentHashObject
- type ConcurrentRWLockObject
- type Decimal
- type DecimalObject
- func (b DecimalObject) Class() *RClass
- func (f *DecimalObject) DecimalValue() interface{}
- func (f *DecimalObject) FloatValue() float64
- func (f *DecimalObject) IntegerValue() int
- func (b DecimalObject) SetSingletonClass(c *RClass)
- func (b DecimalObject) SingletonClass() *RClass
- func (f *DecimalObject) Value() interface{}
- type Diggable
- type Error
- type FileObject
- type Float
- type FloatObject
- type GoMap
- type GoObject
- type HashObject
- type Int
- type IntegerObject
- type Match
- type MatchDataObject
- type MethodObject
- type NullObject
- type Numeric
- type Object
- type PluginObject
- type Pointer
- type RClass
- type RObject
- type RangeObject
- type Regexp
- type RegexpObject
- type StringObject
- type VM
- func (vm *VM) ExecInstructions(sets []*bytecode.InstructionSet, fn string)
- func (vm *VM) GetExecResult() Object
- func (vm *VM) GetREPLResult() string
- func (vm *VM) InitForREPL()
- func (vm *VM) REPLExec(sets []*bytecode.InstructionSet)
- func (vm *VM) SetClassISIndexTable(fn filename)
- func (vm *VM) SetMethodISIndexTable(fn filename)
Constants ¶
const ( NormalMode int = iota REPLMode TestMode )
These are the enums for marking parser's mode, which decides whether it should pop unused values.
const Version = "0.1.9"
Version stores current Goby version
Variables ¶
var ConcurrentArrayMethodsForwardingTable = map[string]bool{ "[]": false, "*": false, "+": false, "[]=": true, "any?": false, "at": false, "clear": true, "concat": true, "count": false, "delete_at": true, "each": false, "each_index": false, "empty?": false, "first": false, "flatten": false, "join": false, "last": false, "length": false, "map": false, "pop": true, "push": true, "reduce": false, "reverse": false, "reverse_each": false, "rotate": false, "select": false, "shift": true, "unshift": true, "values_at": false, }
Pseudo-constant definition of the forwarded methods, mapped to a boolean representing the requirement for a write lock (true) or read lock (false)
We don't implement dig, as it has no concurrency guarantees.
Functions ¶
func PrintError ¶ added in v0.1.3
func PrintError(v *VM)
PrintError prints an error report string given a vm which evaluated to and Error object
Types ¶
type ArrayObject ¶
type ArrayObject struct { Elements []Object // contains filtered or unexported fields }
ArrayObject represents instance from Array class. An array is a collection of different objects that are ordered and indexed. Elements in an array can belong to any class.
func (ArrayObject) SetSingletonClass ¶ added in v0.1.0
func (b ArrayObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (ArrayObject) SingletonClass ¶ added in v0.1.0
func (b ArrayObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*ArrayObject) Value ¶ added in v0.1.0
func (a *ArrayObject) Value() interface{}
Value returns the elements from the object
type BlockObject ¶ added in v0.1.7
type BlockObject struct {
// contains filtered or unexported fields
}
func (BlockObject) Class ¶ added in v0.1.7
func (b BlockObject) Class() *RClass
Class will return object's class
func (BlockObject) SetSingletonClass ¶ added in v0.1.7
func (b BlockObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (BlockObject) SingletonClass ¶ added in v0.1.7
func (b BlockObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*BlockObject) Value ¶ added in v0.1.7
func (bo *BlockObject) Value() interface{}
Value returns the object
type BooleanObject ¶
type BooleanObject struct {
// contains filtered or unexported fields
}
BooleanObject represents boolean object in goby. It includes `true` and `FALSE` which represents logically true and false value. - `Boolean.new` is not supported.
var ( // TRUE is shared boolean object that represents true TRUE *BooleanObject // FALSE is shared boolean object that represents false FALSE *BooleanObject )
func (BooleanObject) Class ¶
func (b BooleanObject) Class() *RClass
Class will return object's class
func (BooleanObject) SetSingletonClass ¶ added in v0.1.0
func (b BooleanObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (BooleanObject) SingletonClass ¶ added in v0.1.0
func (b BooleanObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
type BuiltinMethodObject ¶ added in v0.1.3
type BuiltinMethodObject struct { Name string Fn func(receiver Object, sourceLine int) builtinMethodBody // contains filtered or unexported fields }
BuiltinMethodObject represents methods defined in go.
func DefineForwardedConcurrentArrayMethod ¶ added in v0.1.6
func DefineForwardedConcurrentArrayMethod(methodName string, requireWriteLock bool) *BuiltinMethodObject
func (BuiltinMethodObject) Class ¶ added in v0.1.3
func (b BuiltinMethodObject) Class() *RClass
Class will return object's class
func (BuiltinMethodObject) SetSingletonClass ¶ added in v0.1.3
func (b BuiltinMethodObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (BuiltinMethodObject) SingletonClass ¶ added in v0.1.3
func (b BuiltinMethodObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*BuiltinMethodObject) Value ¶ added in v0.1.6
func (bim *BuiltinMethodObject) Value() interface{}
Value returns builtin method object's function
type ChannelObject ¶ added in v0.0.8
type ChannelObject struct { Chan chan int // contains filtered or unexported fields }
ChannelObject represents a goby channel, which carries a golang channel
func (ChannelObject) Class ¶ added in v0.0.8
func (b ChannelObject) Class() *RClass
Class will return object's class
func (ChannelObject) SetSingletonClass ¶ added in v0.1.0
func (b ChannelObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (ChannelObject) SingletonClass ¶ added in v0.1.0
func (b ChannelObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*ChannelObject) Value ¶ added in v0.1.0
func (co *ChannelObject) Value() interface{}
Value returns the object
type ConcurrentArrayObject ¶ added in v0.1.6
type ConcurrentArrayObject struct { InternalArray *ArrayObject sync.RWMutex // contains filtered or unexported fields }
ConcurrentArrayObject is a thread-safe Array, implemented as a wrapper of an ArrayObject, coupled with an R/W mutex.
Arrays returned by any of the methods are in turn thread-safe.
For implementation simplicity, methods are simple redirection, and defined via a table.
func (ConcurrentArrayObject) Class ¶ added in v0.1.6
func (b ConcurrentArrayObject) Class() *RClass
Class will return object's class
func (ConcurrentArrayObject) SetSingletonClass ¶ added in v0.1.6
func (b ConcurrentArrayObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (ConcurrentArrayObject) SingletonClass ¶ added in v0.1.6
func (b ConcurrentArrayObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*ConcurrentArrayObject) Value ¶ added in v0.1.6
func (cac *ConcurrentArrayObject) Value() interface{}
Value returns the object
type ConcurrentHashObject ¶ added in v0.1.6
type ConcurrentHashObject struct {
// contains filtered or unexported fields
}
ConcurrentHashObject is an implementation of thread-safe associative arrays (Hash).
The implementation internally uses Go's `sync.Map` type, with some advantages and disadvantages:
- it is highly performant and predictable for a certain pattern of usage (`concurrent loops with keys that are stable over time, and either few steady-state stores, or stores localized to one goroutine per key.`); performance and predictability in other conditions are unspecified; - iterations are non-deterministic; during iterations, keys may not be included; - size can't be retrieved; - for the reasons above, the Hash APIs implemented are minimal.
For details, see https://golang.org/pkg/sync/#Map.
```ruby require 'concurrent/hash' hash = Concurrent::Hash.new({ "a": 1, "b": 2 }) hash["a"] # => 1 ```
func (ConcurrentHashObject) Class ¶ added in v0.1.6
func (b ConcurrentHashObject) Class() *RClass
Class will return object's class
func (ConcurrentHashObject) SetSingletonClass ¶ added in v0.1.6
func (b ConcurrentHashObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (ConcurrentHashObject) SingletonClass ¶ added in v0.1.6
func (b ConcurrentHashObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*ConcurrentHashObject) Value ¶ added in v0.1.6
func (h *ConcurrentHashObject) Value() interface{}
Value returns the object
type ConcurrentRWLockObject ¶ added in v0.1.6
type ConcurrentRWLockObject struct {
// contains filtered or unexported fields
}
ConcurrentRWLockObject is a Readers-Writer Lock (readers can concurrently put a lock, while a writer requires exclusive access).
The implementation internally uses Go's `sync.RWLock` type.
```ruby require 'concurrent/rw_lock' lock = Concurrent::RWLock.new lock.with_read_lock do
# critical section
end lock.with_write_lock do
# critical section
end ```
func (ConcurrentRWLockObject) Class ¶ added in v0.1.6
func (b ConcurrentRWLockObject) Class() *RClass
Class will return object's class
func (ConcurrentRWLockObject) SetSingletonClass ¶ added in v0.1.6
func (b ConcurrentRWLockObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (ConcurrentRWLockObject) SingletonClass ¶ added in v0.1.6
func (b ConcurrentRWLockObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*ConcurrentRWLockObject) Value ¶ added in v0.1.6
func (lock *ConcurrentRWLockObject) Value() interface{}
Value returns the object
type DecimalObject ¶ added in v0.1.6
type DecimalObject struct {
// contains filtered or unexported fields
}
(Experiment) DecimalObject represents a comparable decimal number using Go's Rational representation `big.Rat` from math/big package, which consists of a numerator and a denominator with arbitrary size. By using Decimal you can avoid errors on float type during calculations. To keep accuracy, avoid conversions until all calculations have been finished. The numerator can be 0, but the denominator cannot be 0. Using Decimal for loop counters or like that is not recommended (TBD).
```ruby "3.14".to_d # => 3.14 "-0.7238943".to_d # => -0.7238943 "355/113".to_d # => 3.1415929203539823008849557522123893805309734513274336283185840
a = "16.1".to_d b = "1.1".to_d e = "17.2".to_d a + b # => 0.1 a + b == e # => true
('16.1'.to_d + "1.1".to_d).to_s #=> 17.2 ('16.1'.to_f + "1.1".to_f).to_s #=> 17.200000000000003 ```
- `Decimal.new` is not supported.
func (DecimalObject) Class ¶ added in v0.1.6
func (b DecimalObject) Class() *RClass
Class will return object's class
func (*DecimalObject) DecimalValue ¶ added in v0.1.6
func (f *DecimalObject) DecimalValue() interface{}
Alias of Value()
func (*DecimalObject) FloatValue ¶ added in v0.1.6
func (f *DecimalObject) FloatValue() float64
Float interface
func (*DecimalObject) IntegerValue ¶ added in v0.1.6
func (f *DecimalObject) IntegerValue() int
Returns integer part of decimal
func (DecimalObject) SetSingletonClass ¶ added in v0.1.6
func (b DecimalObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (DecimalObject) SingletonClass ¶ added in v0.1.6
func (b DecimalObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*DecimalObject) Value ¶ added in v0.1.6
func (f *DecimalObject) Value() interface{}
Value returns the object
type Diggable ¶ added in v0.1.6
type Diggable interface {
// contains filtered or unexported methods
}
Diggable represents a class that support the #dig method.
type Error ¶
type Error struct { Type string // contains filtered or unexported fields }
Error class is actually a special struct to hold internal error types with messages. Goby developers need not to take care of the struct. Goby maintainers should consider using the appropriate error type. Cannot create instances of Error class, or inherit Error class.
The type of internal errors:
see vm/errors/error.go.
func (Error) SetSingletonClass ¶ added in v0.1.0
func (b Error) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (Error) SingletonClass ¶ added in v0.1.0
func (b Error) SingletonClass() *RClass
SingletonClass returns object's singleton class
type FileObject ¶ added in v0.0.6
FileObject is a special type that contains file pointer so we can keep track on target file.
func (FileObject) Class ¶ added in v0.0.6
func (b FileObject) Class() *RClass
Class will return object's class
func (FileObject) SetSingletonClass ¶ added in v0.1.0
func (b FileObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (FileObject) SingletonClass ¶ added in v0.1.0
func (b FileObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*FileObject) Value ¶ added in v0.1.6
func (f *FileObject) Value() interface{}
Value returns file object's string format
type FloatObject ¶ added in v0.1.6
type FloatObject struct {
// contains filtered or unexported fields
}
FloatObject represents an inexact real number using the native architecture's double-precision floating point representation.
```ruby 1.1 + 1.1 # => 2.2 2.1 * 2.1 # => 4.41 ```
- `Float.new` is not supported.
func (FloatObject) Class ¶ added in v0.1.6
func (b FloatObject) Class() *RClass
Class will return object's class
func (FloatObject) SetSingletonClass ¶ added in v0.1.6
func (b FloatObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (FloatObject) SingletonClass ¶ added in v0.1.6
func (b FloatObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*FloatObject) Value ¶ added in v0.1.6
func (f *FloatObject) Value() interface{}
Value returns the object
type GoMap ¶ added in v0.1.6
type GoMap struct {
// contains filtered or unexported fields
}
GoMap ...
func (GoMap) Class ¶ added in v0.1.6
func (b GoMap) Class() *RClass
Class will return object's class
func (GoMap) SetSingletonClass ¶ added in v0.1.6
func (b GoMap) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (GoMap) SingletonClass ¶ added in v0.1.6
func (b GoMap) SingletonClass() *RClass
SingletonClass returns object's singleton class
type GoObject ¶ added in v0.1.0
type GoObject struct {
// contains filtered or unexported fields
}
GoObject ...
func (GoObject) Class ¶ added in v0.1.0
func (b GoObject) Class() *RClass
Class will return object's class
func (GoObject) SetSingletonClass ¶ added in v0.1.0
func (b GoObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (GoObject) SingletonClass ¶ added in v0.1.0
func (b GoObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
type HashObject ¶
type HashObject struct { Pairs map[string]Object // See `[]` and `[]=` for the operational explanation of the default value. Default Object // contains filtered or unexported fields }
HashObject represents hash instances Hash is a collection of key-value pair, which works like a dictionary. Hash literal is represented with curly brackets `{ }` like `{ key: value }`. Each key of the hash is unique and cannot be duplicate within the hash. Adding a leading space and a trailing space within curly brackets are preferable.
- **Key:** an alphanumeric word that starts with alphabet, without containing space and punctuations. Underscore `_` can also be used within the key. String literal like "mickey mouse" cannot be used as a hash key. The internal key is actually a String and **not a Symbol** for now (TBD). Thus only a String object or a string literal should be used when referencing with `[ ]`.
```ruby a = { balthazar1: 100 } # valid b = { 2melchior: 200 } # invalid x = 'balthazar1'
a["balthazar1"] # => 100 a[x] # => 100 a[balthazar1] # => error ```
- **value:** String literal and objects (Integer, String, Array, Hash, nil, etc) can be used.
**Note:** - The order of key-value pairs are **not** preserved. - Operator `=>` is not supported. - `Hash.new` is not supported.
func (HashObject) SetSingletonClass ¶ added in v0.1.0
func (b HashObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (HashObject) SingletonClass ¶ added in v0.1.0
func (b HashObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*HashObject) Value ¶ added in v0.1.0
func (h *HashObject) Value() interface{}
Value returns the object
type IntegerObject ¶
type IntegerObject struct {
// contains filtered or unexported fields
}
IntegerObject represents number objects which can bring into mathematical calculations.
```ruby 1 + 1 # => 2 2 * 2 # => 4 ```
- `Integer.new` is not supported.
func (IntegerObject) Class ¶
func (b IntegerObject) Class() *RClass
Class will return object's class
func (IntegerObject) SetSingletonClass ¶ added in v0.1.0
func (b IntegerObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (IntegerObject) SingletonClass ¶ added in v0.1.0
func (b IntegerObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
type Match ¶ added in v0.1.6
MatchDataObject represents the match data returned by a regular expression matching operation. You can use named-captures via `(?<name>)`.
```ruby 'abcd'.match(Regexp.new('(b.)')) #=> #<MatchData 0:"bc" 1:"bc">
'abcd'.match(Regexp.new('a(?<first>b)(?<second>c)')) #=> #<MatchData 0:"abc" first:"b" second:"c"> ```
- `MatchData.new` is not supported.
type MatchDataObject ¶ added in v0.1.6
type MatchDataObject struct {
// contains filtered or unexported fields
}
func (MatchDataObject) Class ¶ added in v0.1.6
func (b MatchDataObject) Class() *RClass
Class will return object's class
func (MatchDataObject) SetSingletonClass ¶ added in v0.1.6
func (b MatchDataObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (MatchDataObject) SingletonClass ¶ added in v0.1.6
func (b MatchDataObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*MatchDataObject) Value ¶ added in v0.1.6
func (m *MatchDataObject) Value() interface{}
redirects to toString()
type MethodObject ¶ added in v0.0.5
type MethodObject struct { Name string // contains filtered or unexported fields }
MethodObject represents methods defined using goby.
func (MethodObject) Class ¶ added in v0.0.9
func (b MethodObject) Class() *RClass
Class will return object's class
func (MethodObject) SetSingletonClass ¶ added in v0.1.0
func (b MethodObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (MethodObject) SingletonClass ¶ added in v0.1.0
func (b MethodObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*MethodObject) Value ¶ added in v0.1.6
func (m *MethodObject) Value() interface{}
Value returns method object's string format
type NullObject ¶ added in v0.0.5
type NullObject struct {
// contains filtered or unexported fields
}
NullObject (`nil`) represents the null value in Goby. `nil` is convert into `null` when exported to JSON format. - `Null.new` is not supported.
var ( // NULL represents Goby's null objects. NULL *NullObject )
func (NullObject) Class ¶ added in v0.0.5
func (b NullObject) Class() *RClass
Class will return object's class
func (NullObject) SetSingletonClass ¶ added in v0.1.0
func (b NullObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (NullObject) SingletonClass ¶ added in v0.1.0
func (b NullObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*NullObject) Value ¶ added in v0.1.0
func (n *NullObject) Value() interface{}
Value returns the object
type Numeric ¶ added in v0.1.6
type Numeric interface {
// contains filtered or unexported methods
}
Numeric currently represents a class that support some numeric conversions. At this stage, it's not meant to be a Goby class in a strict sense, but only a convenient interface.
type Object ¶
type Object interface { Class() *RClass Value() interface{} SingletonClass() *RClass SetSingletonClass(*RClass) // contains filtered or unexported methods }
Object represents all objects in Goby, including Array, Integer or even Method and Error.
type PluginObject ¶ added in v0.1.0
type PluginObject struct {
// contains filtered or unexported fields
}
PluginObject is a special type that contains a Go's plugin
func (PluginObject) Class ¶ added in v0.1.0
func (b PluginObject) Class() *RClass
Class will return object's class
func (PluginObject) SetSingletonClass ¶ added in v0.1.0
func (b PluginObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (PluginObject) SingletonClass ¶ added in v0.1.0
func (b PluginObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*PluginObject) Value ¶ added in v0.1.6
func (p *PluginObject) Value() interface{}
Value returns plugin object's string format
type Pointer ¶
type Pointer struct { Target Object // contains filtered or unexported fields }
Pointer is used to point to an object. Variables should hold pointer instead of holding a object directly.
type RClass ¶
type RClass struct { // Name is the class's name Name string // Methods contains its instances' methods Methods *environment // contains filtered or unexported fields }
RClass represents normal (not built in) class object
func (RClass) Class ¶ added in v0.0.9
func (b RClass) Class() *RClass
Class will return object's class
func (*RClass) ReturnName ¶ added in v0.0.9
ReturnName returns the object's name as the string format
func (RClass) SetSingletonClass ¶ added in v0.1.0
func (b RClass) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (RClass) SingletonClass ¶ added in v0.1.0
func (b RClass) SingletonClass() *RClass
SingletonClass returns object's singleton class
type RObject ¶
type RObject struct { InitializeMethod *MethodObject // contains filtered or unexported fields }
RObject represents any non built-in class's instance.
func (RObject) SetSingletonClass ¶ added in v0.1.0
func (b RObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (RObject) SingletonClass ¶ added in v0.1.0
func (b RObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
type RangeObject ¶ added in v0.0.9
RangeObject is the built in range class Range represents an interval: a set of values from the beginning to the end specified. Currently, only Integer objects or integer literal are supported.
```ruby r = 0 (1..(1+4)).each do |i|
puts(r = r + i)
end ```
```ruby r = 0 a = 1 b = 5 (a..b).each do |i|
r = r + i
end ```
func (RangeObject) Class ¶ added in v0.0.9
func (b RangeObject) Class() *RClass
Class will return object's class
func (RangeObject) SetSingletonClass ¶ added in v0.1.0
func (b RangeObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (RangeObject) SingletonClass ¶ added in v0.1.0
func (b RangeObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*RangeObject) Value ¶ added in v0.1.6
func (ro *RangeObject) Value() interface{}
Value returns range object's string format
type Regexp ¶ added in v0.1.6
RegexpObject represents regexp instances, which of the type is actually string. Regexp object holds regexp strings. Powered by: github.com/dlclark/regexp2 The regexp2 package had been ported from .NET Framework's regexp library, which is PCRE-compatible and is almost all equivalent to Ruby's Onigmo regexp library.
```ruby a = Regexp.new("orl") a.match?("Hello World") #=> true a.match?("Hello Regexp") #=> false
b = Regexp.new("😏") b.match?("🤡 😏 😐") #=> true b.match?("😝 😍 😊") #=> false
c = Regexp.new("居(ら(?=れ)|さ(?=せ)|る|ろ|れ(?=[ばる])|よ|(?=な[いかくけそ]|ま[しすせ]|そう|た|て))") c.match?("居られればいいのに") #=> true c.match?("居ずまいを正す") #=> false ```
**Note:**
- Currently, manipulations are based upon Golang's Unicode manipulations. - Currently, UTF-8 encoding is assumed based upon Golang's string manipulation, but the encoding is not actually specified(TBD). - `Regexp.new` is exceptionally supported.
**To Goby maintainers**: avoid using Go's standard regexp package (slow and not rich). Consider the faster `Trim` or `Split` etc in Go's "strings" package first, or just use the dlclark/regexp2 instead. ToDo: Regexp literals with '/.../'
type RegexpObject ¶ added in v0.1.6
type RegexpObject struct {
// contains filtered or unexported fields
}
func (RegexpObject) Class ¶ added in v0.1.6
func (b RegexpObject) Class() *RClass
Class will return object's class
func (RegexpObject) SetSingletonClass ¶ added in v0.1.6
func (b RegexpObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (RegexpObject) SingletonClass ¶ added in v0.1.6
func (b RegexpObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
func (*RegexpObject) Value ¶ added in v0.1.6
func (r *RegexpObject) Value() interface{}
Value returns the object
type StringObject ¶
type StringObject struct {
// contains filtered or unexported fields
}
StringObject represents string instances String object holds and manipulates a sequence of characters. String objects may be created using as string literals. Double or single quotations can be used for representation.
```ruby a = "Three" b = 'zero' c = '漢' d = 'Tiếng Việt' e = "😏️️" ```
**Note:**
- Currently, manipulations are based upon Golang's Unicode manipulations. - Currently, UTF-8 encoding is assumed based upon Golang's string manipulation, but the encoding is not actually specified(TBD). - `String.new` is not supported.
func (StringObject) SetSingletonClass ¶ added in v0.1.0
func (b StringObject) SetSingletonClass(c *RClass)
SetSingletonClass sets object's singleton class
func (StringObject) SingletonClass ¶ added in v0.1.0
func (b StringObject) SingletonClass() *RClass
SingletonClass returns object's singleton class
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM represents a stack based virtual machine.
func InitIssueReportVM ¶ added in v0.1.3
InitIssueReportVM initializes a vm in test mode for issue reporting
func (*VM) ExecInstructions ¶ added in v0.0.9
func (vm *VM) ExecInstructions(sets []*bytecode.InstructionSet, fn string)
ExecInstructions accepts a sequence of bytecodes and use vm to evaluate them.
func (*VM) GetExecResult ¶
GetExecResult returns stack's top most value. Normally it's used in tests.
func (*VM) GetREPLResult ¶ added in v0.0.9
GetREPLResult returns strings that should be showed after each evaluation.
func (*VM) InitForREPL ¶ added in v0.0.9
func (vm *VM) InitForREPL()
InitForREPL does following things: - Initialize instruction sets' index tables - Set vm to REPL mode - Create and push main object frame
func (*VM) REPLExec ¶ added in v0.0.9
func (vm *VM) REPLExec(sets []*bytecode.InstructionSet)
REPLExec executes instructions differently from normal program execution.
func (*VM) SetClassISIndexTable ¶ added in v0.0.9
func (vm *VM) SetClassISIndexTable(fn filename)
SetClassISIndexTable adds new instruction set's index table to vm.classISIndexTables
func (*VM) SetMethodISIndexTable ¶ added in v0.0.9
func (vm *VM) SetMethodISIndexTable(fn filename)
SetMethodISIndexTable adds new instruction set's index table to vm.methodISIndexTables
Source Files ¶
- array.go
- block.go
- boolean.go
- call_frame.go
- call_object.go
- channel.go
- class.go
- concurrent_array.go
- concurrent_hash.go
- concurrent_rw_lock.go
- db.go
- decimal.go
- diggable.go
- environment.go
- error.go
- file.go
- float.go
- go_map.go
- go_object.go
- hash.go
- http.go
- http_client.go
- inspection_methods.go
- instruction.go
- instruction_translator.go
- integer.go
- issue_vm.go
- json.go
- match_data.go
- method.go
- null.go
- numeric.go
- object.go
- plugin.go
- plugin_generator.go
- range.go
- regexp.go
- repl.go
- simple_server.go
- spec.go
- stack.go
- string.go
- thread.go
- uri.go
- vm.go