engine

package
v1.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColorReset  = "\033[0m"
	ColorRed    = "\033[31m"
	ColorGreen  = "\033[32m"
	ColorYellow = "\033[33m"
	ColorBlue   = "\033[34m"
	ColorPurple = "\033[35m"
	ColorCyan   = "\033[36m"
	ColorGray   = "\033[90m"
	ColorWhite  = "\033[97m"

	ColorBoldRed    = "\033[1;31m"
	ColorBoldGreen  = "\033[1;32m"
	ColorBoldYellow = "\033[1;33m"
	ColorBoldBlue   = "\033[1;34m"
	ColorBoldCyan   = "\033[1;36m"
)

ANSI color codes

Variables

View Source
var NewEnv = common.NewEnv

Use common definitions for Env and Func

View Source
var NewEnvWithContext = common.NewEnvWithContext

Functions

func ArrayToSlice added in v1.0.0

func ArrayToSlice(env *Env, arrayInstance *ClassInstance) ([]any, error)

ArrayToSlice converts an Array instance to a Go []any for JSON serialization

func AsBytes added in v1.1.0

func AsBytes(env *common.Env, value any) ([]byte, bool)

func BoolValue added in v1.0.0

func BoolValue(v any) (bool, bool)

BoolValue extracts the Go bool value from a Bool instance or converts a value to bool

func CallInstanceMethod added in v1.1.0

func CallInstanceMethod(instance *ClassInstance, methodInfo MethodInfo, env *Env, args []any) (any, error)

CallInstanceMethod calls a method on an instance

func ClassInstanceToArray added in v1.0.0

func ClassInstanceToArray(instance *ClassInstance) ([]any, error)

func ClassInstanceToArrayTypeString added in v1.0.0

func ClassInstanceToArrayTypeString(instance *ClassInstance) (string, error)

func ConvertMapKey added in v1.1.0

func ConvertMapKey(env *Env, key any) any

ConvertMapKey converts a key to the appropriate type for use in a Map

func ConvertMapValue added in v1.1.0

func ConvertMapValue(env *Env, value any) any

ConvertMapValue converts a value to the appropriate type for storage in a Map

func ConvertTo added in v1.1.0

func ConvertTo(env *common.Env, typeName string, value any) (any, bool)

ConvertTo attempts to convert a value to the specified type using registered converters

func ConvertToClassInstance added in v1.1.0

func ConvertToClassInstance(env *Env, value any) any

CreateArrayInstance creates an Array instance from a []any ConvertToClassInstance converts native Go types to their ClassInstance equivalents recursively

func CreateBiFunctionInstance added in v1.0.0

func CreateBiFunctionInstance(lambda *ast.LambdaExpr, env *Env) (map[string]any, error)

CreateBiFunctionInstance creates an instance of BiFunction interface from a lambda

func CreateFunctionInstance added in v1.0.0

func CreateFunctionInstance(lambda *ast.LambdaExpr, env *Env) (map[string]any, error)

CreateFunctionInstance creates an instance of Function interface from a lambda

func CreateGenericInstance added in v1.0.0

func CreateGenericInstance(env *Env, value any) (any, error)

CreateGenericInstance creates a Generic instance wrapping a native Go value

func Eval

func Eval(prog *ast.Program, opts Options) (any, error)

func EvalWithContext

func EvalWithContext(prog *ast.Program, opts Options, fileName, packageName string) (any, error)

func EvalWithContextAndSource

func EvalWithContextAndSource(prog *ast.Program, opts Options, fileName, packageName, source string) (any, error)

func FastIntOperation added in v1.1.4

func FastIntOperation(op int, a, b int) int

FastIntOperation performs optimized integer arithmetic

func FloatValue added in v1.0.0

func FloatValue(v any) (float64, bool)

FloatValue extracts the Go float64 value from a Float instance or converts a value to float64

func FormatError

func FormatError(err error) string

FormatError formats a HyException with colors and hints

func FormatErrorPlain

func FormatErrorPlain(err error) string

FormatErrorPlain formats an error without colors (for non-terminal output)

func FormatErrorPlainWithContext

func FormatErrorPlainWithContext(err error, codeContext []string, currentLine int) string

FormatErrorPlainWithContext formats an error without colors but with code context

func FormatErrorWithContext

func FormatErrorWithContext(err error, codeContext []string, currentLine int) string

FormatErrorWithContext formats a HyException with code context if available

func GetCachedFloat added in v1.0.0

func GetCachedFloat(n float64) float64

GetCachedFloat returns a cached float for common values

func GetCachedInt added in v1.0.0

func GetCachedInt(n int) int

GetCachedInt returns a cached integer for small values

func GetCachedString added in v1.0.0

func GetCachedString(s string) string

GetCachedString returns a cached string if available, otherwise returns the input

func GetGenericValue added in v1.1.0

func GetGenericValue(instance *ClassInstance) (any, error)

func GetItemsFromCollection added in v1.1.0

func GetItemsFromCollection(env *Env, collection *ClassInstance) (any, error)

func GetPooledEnv added in v1.1.4

func GetPooledEnv(parent *common.Env) *common.Env

GetPooledEnv gets an environment from the pool and initializes it

func GetTypeName added in v1.1.0

func GetTypeName(val any) string

GetTypeName returns the type name for any value This is the implementation for Sys.type() function Returns lowercase names for primitives, and formatted names for classes/enums

func InitFunctionInterfaces added in v1.0.0

func InitFunctionInterfaces(env *Env) error

InitFunctionInterfaces initializes the Function and BiFunction interfaces

func InitializeAnnotationBase added in v0.2.0

func InitializeAnnotationBase(env *common.Env)

InitializeAnnotationBase registers the base Annotation class

func InitializeAnnotationInterfaces added in v0.2.0

func InitializeAnnotationInterfaces(env *common.Env)

InitializeAnnotationInterfaces registers the built-in annotation interfaces

func InitializeBuiltinInstanceCreators added in v1.1.0

func InitializeBuiltinInstanceCreators()

InitializeBuiltinInstanceCreators registers all builtin instance creators

func InitializeBuiltinTypeConverters added in v1.1.0

func InitializeBuiltinTypeConverters()

InitializeBuiltinTypeConverters registers all builtin type converters

func InstallArrayBuiltin added in v1.0.0

func InstallArrayBuiltin(env *Env) error

InstallArrayBuiltin installs the Array builtin type using ClassBuilder Array is now a minimal base class with only basic operations

func InstallAsyncAwait added in v1.0.0

func InstallAsyncAwait(env *common.Env)

InstallAsyncAwait sets up async/await support in the environment using ClassBuilder

func InstallBoolBuiltin added in v1.0.0

func InstallBoolBuiltin(env *Env) error

InstallBoolBuiltin installs Bool builtin type as a class

func InstallBytesBuiltin added in v1.1.0

func InstallBytesBuiltin(env *Env) error

InstallBytesBuiltin installs the Bytes builtin class for handling byte arrays

func InstallChannelBuiltin added in v1.0.0

func InstallChannelBuiltin(env *Env) error

InstallChannelBuiltin creates the builtin Channel class

func InstallCollectionInterface added in v1.1.0

func InstallCollectionInterface(env *Env) error

func InstallCryptoModule

func InstallCryptoModule(env *Env, opts Options) error

InstallCryptoModule installs the complete Crypto module with cryptographic functions

func InstallDequeBuiltin added in v1.0.0

func InstallDequeBuiltin(env *Env) error

InstallDequeBuiltin installs the Deque<T> (double-ended queue) builtin class

func InstallExceptionBuiltins

func InstallExceptionBuiltins(env *Env)

InstallExceptionBuiltins installs exception-related built-ins

func InstallGenericBuiltin added in v1.0.0

func InstallGenericBuiltin(env *Env) error

InstallGenericBuiltin installs the Generic builtin type Generic wraps any native Go value and provides conversion methods

func InstallGenerics added in v1.0.0

func InstallGenerics(env *common.Env)

InstallGenerics sets up generic type support in the environment NOTE: List, Set, Map, and Deque are now installed via InstallGenericCollections using builder pattern This function now only installs Lambda (legacy support)

func InstallHttpModule added in v1.0.0

func InstallHttpModule(env *Env, opts Options)

InstallHttpModule installs the HTTP module using the builder pattern

func InstallIOModule

func InstallIOModule(env *Env, opts Options) error

func InstallIndexableInterface added in v1.1.0

func InstallIndexableInterface(env *Env) error

func InstallIterableInterface added in v1.0.0

func InstallIterableInterface(env *Env) error

These 2 should be used on "for ... in ..." constructs so if the object implements Iterable, it can be iterated over If not, an error is raised also the unstructured interface is used to serialize objects in pieces exmaple a List is n pieces, each piece is an element of the list so can iterate but what if the list have object that can be unstructured too? then for (a,b,c...) in list would work too example the list is [ [1,2], [3,4] ] //but that would just work if all the elements on the lsit are unstructured and have the same number of pieces and the for (n...) have the same number of variables also unstructures can be used to do things like a, b = obj , where obj can be unstructured into 2 pieces or a, b, c = obj where obj can be unstructured into 3 pieces if the number not match an error is raised

The Range class is iterable but not unstructured, so it doesn't save items in memory, it just creates a "counter" to iterate from a number to another. By default, 1...3 that used to convert to [1,2,3] now converts to range(1,3).“ Still iterable, but to be an array use Array(1...3) or when it's a variable like const a = 1...3, use a.toArray()

func InstallListBuiltin added in v1.0.0

func InstallListBuiltin(env *Env) error

InstallListBuiltin installs the List<T> builtin class

func InstallMapBuiltin added in v1.0.0

func InstallMapBuiltin(env *Env) error

func InstallMathModule

func InstallMathModule(env *Env)

InstallMathModule installs the Math module with all mathematical functions

func InstallNetModule

func InstallNetModule(env *Env, opts Options)

InstallNetModule installs the complete Net module with networking functions

func InstallNumberBuiltin added in v1.0.0

func InstallNumberBuiltin(env *Env) error

InstallNumberBuiltin installs Int and Float builtin types as classes

func InstallPairBuiltin added in v1.0.0

func InstallPairBuiltin(env *Env) error

InstallPairBuiltin creates the Pair<K,V> class for key-value pairs (formerly MapEntry)

func InstallRangeBuiltin added in v1.0.0

func InstallRangeBuiltin(env *Env) error

InstallRangeBuiltin installs the Range builtin type Range is an iterable that doesn't store items in memory, just a counter

func InstallSerializableInterface added in v1.0.0

func InstallSerializableInterface(env *Env) error

func InstallSetBuiltin added in v1.0.0

func InstallSetBuiltin(env *Env) error

InstallSetBuiltin installs the Set<T> builtin class

func InstallSliceableInterface added in v1.1.0

func InstallSliceableInterface(env *Env) error

func InstallSocketsModule added in v1.1.0

func InstallSocketsModule(env *Env, opts Options) error

InstallSocketsModule installs Socket classes for network communication

func InstallStringBuiltin added in v1.0.0

func InstallStringBuiltin(env *Env) error

InstallStringBuiltin installs String builtin type as a class

func InstallSysModule

func InstallSysModule(env *Env, opts Options)

InstallSysModule installs the complete Sys module with all functions

func InstallTupleClass added in v1.0.0

func InstallTupleClass(env *Env) error

InstallTupleClass installs the Tuple builtin class Tuple is an immutable sequence that implements Unstructured interface

func InstallUnstructuredInterface added in v1.0.0

func InstallUnstructuredInterface(env *Env) error

func IntValue added in v1.0.0

func IntValue(v any) (int, bool)

IntValue extracts the Go int value from an Integer instance or converts a value to int

func IsBiFunction added in v1.0.0

func IsBiFunction(val any) bool

IsBiFunction checks if a value implements the BiFunction interface

func IsClassInstanceOfDefinition added in v1.1.0

func IsClassInstanceOfDefinition(instance *common.ClassInstance, class *common.ClassDefinition) bool

IsClassInstanceOfDefinition checks if a class instance matches a class definition. This is used when comparing against a ClassConstructor or ClassDefinition directly.

func IsFunction added in v1.0.0

func IsFunction(val any) bool

IsFunction checks if a value implements the Function interface

func IsInstanceOf

func IsInstanceOf(value any, typeName string) bool

IsInstanceOf checks if a value is an instance of the given type name This is the core type checking function used throughout the system Supports: basic types, generic types (Array<Int>), union types (Int | String), wildcards (? extends Number)

func IsTerminal

func IsTerminal() bool

IsTerminal checks if the output supports colors (simplified check)

func MapToClassMap added in v1.1.0

func MapToClassMap(mapInstance *ClassInstance) (map[*ClassInstance]*ClassInstance, error)

func MapToData added in v1.1.0

func MapToData(env *Env, value any) (map[string]any, bool)

MapToData converts various types to a map[string]any representation

func MapToObject added in v1.0.0

func MapToObject(env *Env, mapInstance *ClassInstance) (map[string]any, error)

MapToObject converts a Map instance back to a Go map[string]any for JSON serialization

func RegisterInstanceCreator added in v1.1.0

func RegisterInstanceCreator(typeName string, creator InstanceCreator)

RegisterInstanceCreator registers a creator for a specific type

func RegisterTypeConverter added in v1.1.0

func RegisterTypeConverter(typeName string, converter TypeConverter)

RegisterTypeConverter registers a converter for a specific type

func ReleaseEnv added in v1.1.4

func ReleaseEnv(env *common.Env)

ReleaseEnv returns an environment to the pool

func ResetGlobalRegistries added in v1.0.0

func ResetGlobalRegistries()

ResetGlobalRegistries clears all global registries. This is primarily used for testing to ensure tests don't affect each other.

func SortSuggestionsByRelevance

func SortSuggestionsByRelevance(suggestions []string, target string) []string

SortSuggestionsByRelevance sorts suggestions by their similarity to the target

func StringValue added in v1.0.0

func StringValue(v any) string

StringValue extracts the Go string value from a String instance or converts a value to string

func ThrowAccessError

func ThrowAccessError(env *Env, memberName string, containerName string, accessLevel string) error

ThrowAccessError throws an error when trying to access private/protected members

func ThrowArityError

func ThrowArityError(env *Env, expected, got int) error

ThrowArityError throws an ArityError exception

func ThrowAttributeError

func ThrowAttributeError(env *Env, attrName string, typeName string) error

ThrowAttributeError throws an AttributeError exception for missing attributes/fields

func ThrowAttributeErrorWithHint added in v1.0.0

func ThrowAttributeErrorWithHint(env *Env, attrName string, typeName string, availableMethods []string) error

func ThrowConversionError added in v1.0.0

func ThrowConversionError(env *Env, value any, targetType string) error

ThrowConversionError throws a ConversionError exception for type conversion failures

func ThrowIndexError added in v1.0.0

func ThrowIndexError(env *Env, index, size int, collectionType string) error

ThrowIndexError throws an IndexError exception for out-of-bounds access

func ThrowInitializationError added in v1.0.0

func ThrowInitializationError(env *Env, what string) error

ThrowInitializationError throws an InitializationError exception

func ThrowNameError

func ThrowNameError(env *Env, name string) error

ThrowNameError throws a NameError exception for undefined names/identifiers

func ThrowNotCallableError

func ThrowNotCallableError(env *Env, objectType string, value string) error

ThrowNotCallableError throws an error when trying to call a non-callable object

func ThrowNotImplementedError

func ThrowNotImplementedError(env *Env, feature string) error

ThrowNotImplementedError throws an error for unimplemented features

func ThrowRuntimeError

func ThrowRuntimeError(env *Env, message string) error

ThrowRuntimeError throws a RuntimeError exception Position information (file, line, column) is automatically retrieved from env

func ThrowStateError added in v1.0.0

func ThrowStateError(env *Env, message string) error

ThrowStateError throws a StateError exception for invalid state operations

func ThrowTypeError

func ThrowTypeError(env *Env, expected string, got ...any) error

ThrowTypeError throws a TypeError exception Position information (file, line, column) is automatically retrieved from env

func ThrowValueError

func ThrowValueError(env *Env, message string) error

ThrowValueError throws a ValueError exception for invalid values

func ValidateArgumentType added in v1.0.0

func ValidateArgumentType(value any, expectedType string) error

ValidateArgumentType validates that an argument matches the expected type

func ValidateFunctionArguments added in v1.0.0

func ValidateFunctionArguments(args []any, paramTypes []string, hasVariadic bool, variadicType string) ([]any, error)

ValidateFunctionArguments validates all function arguments including variadic ones

func ValidateVariadicArguments added in v1.0.0

func ValidateVariadicArguments(args []any, expectedType string) ([]any, error)

ValidateVariadicArguments validates variadic arguments and converts them to an array

func WrapLambdaAsFunction added in v1.0.0

func WrapLambdaAsFunction(lambda *ast.LambdaExpr, env *Env) (common.Func, error)

WrapLambdaAsFunction wraps a lambda expression as a Function interface implementation

Types

type AnnotationInstance added in v0.2.0

type AnnotationInstance struct {
	AnnotationClass *common.ClassDefinition
	Instance        *common.ClassInstance
	RawName         string
}

AnnotationInstance represents a runtime instance of an annotation

type ClassBuilder

type ClassBuilder struct {
	Type *ast.Type
	// contains filtered or unexported fields
}

ClassBuilder facilita la creación de clases builtin con soporte completo para genéricos

func NewClassBuilder

func NewClassBuilder(name string) *ClassBuilder

NewClassBuilder crea un nuevo builder para clases

func (*ClassBuilder) AddAlias added in v1.0.0

func (cb *ClassBuilder) AddAlias(alias string) *ClassBuilder

func (*ClassBuilder) AddBuiltinConstructor added in v1.0.0

func (cb *ClassBuilder) AddBuiltinConstructor(params []ast.Parameter, fn common.Func) *ClassBuilder

AddBuiltinConstructor agrega un constructor builtin (implementado en Go, supports overloading)

func (*ClassBuilder) AddBuiltinMethod

func (cb *ClassBuilder) AddBuiltinMethod(name string, returnType *ast.Type, params []ast.Parameter, fn common.Func, modifiers []string) *ClassBuilder

AddBuiltinMethod agrega un método builtin (implementado en Go, supports overloading)

func (*ClassBuilder) AddConstructor added in v1.0.0

func (cb *ClassBuilder) AddConstructor(params []ast.Parameter, body []ast.Stmt) *ClassBuilder

AddConstructor agrega un constructor a la clase (supports overloading)

func (*ClassBuilder) AddField

func (cb *ClassBuilder) AddField(name string, fieldType *ast.Type, modifiers []string) *ClassBuilder

AddField agrega un campo a la clase

func (*ClassBuilder) AddInterface

func (cb *ClassBuilder) AddInterface(interfaceDef *common.InterfaceDefinition) *ClassBuilder

AddInterface agrega una interfaz implementada

func (*ClassBuilder) AddMethod

func (cb *ClassBuilder) AddMethod(name string, returnType *ast.Type, params []ast.Parameter, body []ast.Stmt, modifiers []string) *ClassBuilder

AddMethod agrega un método a la clase (supports overloading)

func (*ClassBuilder) AddMethodWithParams added in v1.0.0

func (cb *ClassBuilder) AddMethodWithParams(name string, returnType *ast.Type, paramNames []string, paramTypes []*ast.Type, fn common.Func) *ClassBuilder

AddMethodWithParams agrega un método con parámetros especificados por nombres y tipos

func (*ClassBuilder) AddSimpleMethod added in v1.0.0

func (cb *ClassBuilder) AddSimpleMethod(name string, returnType *ast.Type, fn common.Func) *ClassBuilder

AddSimpleMethod agrega un método sin parámetros que retorna un valor

func (*ClassBuilder) AddStaticField added in v1.0.0

func (cb *ClassBuilder) AddStaticField(name string, value any) *ClassBuilder

AddStaticField agrega un campo estático a la clase

func (*ClassBuilder) AddStaticMethod added in v1.0.0

func (cb *ClassBuilder) AddStaticMethod(name string, returnType *ast.Type, params []ast.Parameter, fn common.Func) *ClassBuilder

AddStaticMethod agrega un método estático a la clase (supports overloading)

func (*ClassBuilder) AddTypeParameters added in v1.0.0

func (cb *ClassBuilder) AddTypeParameters(typeParams []common.GenericType) *ClassBuilder

AddTypeParameters agrega múltiples parámetros de tipo genérico

func (*ClassBuilder) Build

func (cb *ClassBuilder) Build(env *Env) (*ClassDefinition, error)

Build construye y registra la clase

func (*ClassBuilder) BuildAndGet

func (cb *ClassBuilder) BuildAndGet(env *Env) (*ClassDefinition, common.Func, error)

BuildAndGet construye la clase y retorna tanto la definición como el constructor

func (*ClassBuilder) BuildStatic added in v1.0.0

func (cb *ClassBuilder) BuildStatic(env *Env) (*ClassDefinition, error)

BuildStatic construye y registra una clase con solo miembros estáticos (no instanciable) Para módulos como Math, Sys, IO que solo tienen métodos y campos estáticos

func (*ClassBuilder) GetType added in v1.0.0

func (cb *ClassBuilder) GetType() *ast.Type

GetType returns the ast.Type reference for this class builder This should be called after all AddAlias calls to ensure aliases are synchronized

func (*ClassBuilder) SetAbstract

func (cb *ClassBuilder) SetAbstract(isAbstract bool) *ClassBuilder

SetAbstract marca la clase como abstracta

func (*ClassBuilder) SetBuiltinConstructor

func (cb *ClassBuilder) SetBuiltinConstructor(params []ast.Parameter, fn common.Func) *ClassBuilder

SetBuiltinConstructor establece un constructor builtin (deprecated, use AddBuiltinConstructor for overloading)

func (*ClassBuilder) SetConstructor

func (cb *ClassBuilder) SetConstructor(params []ast.Parameter, body []ast.Stmt) *ClassBuilder

SetConstructor establece el constructor de la clase (deprecated, use AddConstructor for overloading)

func (*ClassBuilder) SetParent

func (cb *ClassBuilder) SetParent(parent *ClassDefinition) *ClassBuilder

SetParent establece la clase padre

type ClassDefinition

type ClassDefinition = common.ClassDefinition

type ClassInstance

type ClassInstance = common.ClassInstance

func CreateArrayInstance added in v1.0.0

func CreateArrayInstance(env *Env, items []any) (*ClassInstance, error)

func CreateBoolInstance added in v1.0.0

func CreateBoolInstance(env *Env, value bool) (*ClassInstance, error)

CreateBoolInstance creates a Bool instance from a Go bool This is used when evaluating boolean literals

func CreateBytesInstance added in v1.1.0

func CreateBytesInstance(env *common.Env, data any) (*ClassInstance, error)

func CreateFloatInstance added in v1.0.0

func CreateFloatInstance(env *Env, value float64) (*ClassInstance, error)

CreateFloatInstance creates a Float instance from a Go float64 This is used when evaluating float literals

func CreateInstanceFor added in v1.1.0

func CreateInstanceFor(env *common.Env, typeName string, value any) (*ClassInstance, error)

CreateInstanceFor attempts to create a ClassInstance for the specified type

func CreateIntInstance added in v1.0.0

func CreateIntInstance(env *Env, value int) (*ClassInstance, error)

CreateIntInstance creates an Integer instance from a Go int This is used when evaluating integer literals

func CreateMapInstance added in v1.0.0

func CreateMapInstance(env *Env, data any) (*ClassInstance, error)

func CreateRangeInstance added in v1.0.0

func CreateRangeInstance(env *Env, start, end int, step ...int) (*ClassInstance, error)

CreateRangeInstance creates a Range instance from start, end, and optional step

func CreateStringInstance added in v1.0.0

func CreateStringInstance(env *Env, value string) (*ClassInstance, error)

CreateStringInstance creates a String instance from a Go string This is used when evaluating string literals

func GetClassInstance

func GetClassInstance(val any) (*ClassInstance, bool)

GetClassInstance safely casts a value to a ClassInstance

type CompletableFuture added in v1.0.0

type CompletableFuture struct {
	// contains filtered or unexported fields
}

CompletableFuture represents a Java-style completable future

type ConstructorInfo

type ConstructorInfo = common.ConstructorInfo

type EnumBuilder added in v1.0.0

type EnumBuilder struct {
	Type *ast.Type
	// contains filtered or unexported fields
}

func NewEnumBuilder added in v1.0.0

func NewEnumBuilder(name string) *EnumBuilder

NewEnumBuilder crea un nuevo builder para enums

func (*EnumBuilder) AddValue added in v1.0.0

func (eb *EnumBuilder) AddValue(value string) *EnumBuilder

AddValue agrega un valor al enum

func (*EnumBuilder) AddValues added in v1.0.0

func (eb *EnumBuilder) AddValues(values ...string) *EnumBuilder

AddValues agrega múltiples valores al enum

func (*EnumBuilder) Build added in v1.0.0

func (eb *EnumBuilder) Build(env *Env) (map[string]any, error)

Build construye y registra el enum

type EnumValue added in v1.0.0

type EnumValue struct {
	EnumName string
	Value    string
}

EnumValue representa un valor de enum

type Env

type Env = common.Env

Env represents an environment, using the common definition

type ExceptionHint

type ExceptionHint struct {
	Message     string
	Suggestions []string
	HintType    string // "typo", "language_conversion", "general"
}

ExceptionHint provides contextual suggestions for errors

func GetGeneralHint

func GetGeneralHint(errorType string, context string) *ExceptionHint

GetGeneralHint provides context-specific hints based on error type

type FieldInfo

type FieldInfo = common.FieldInfo

type Func

type Func = common.Func

Func represents a callable value, using the common definition

type FunctionBuilder added in v1.0.0

type FunctionBuilder struct {
	// contains filtered or unexported fields
}

FunctionBuilder facilita la creación de funciones builtin

func NewFunctionBuilder added in v1.0.0

func NewFunctionBuilder(name string) *FunctionBuilder

NewFunctionBuilder crea un nuevo builder para funciones

func (*FunctionBuilder) Build added in v1.0.0

func (fb *FunctionBuilder) Build(env *Env) (common.Func, error)

Build construye y registra la función en el entorno

func (*FunctionBuilder) SetAccessLevel added in v1.0.0

func (fb *FunctionBuilder) SetAccessLevel(accessLevel string) *FunctionBuilder

SetAccessLevel establece el nivel de acceso

func (*FunctionBuilder) SetImplementation added in v1.0.0

func (fb *FunctionBuilder) SetImplementation(impl common.Func) *FunctionBuilder

SetImplementation establece la implementación de la función

func (*FunctionBuilder) SetParams added in v1.0.0

func (fb *FunctionBuilder) SetParams(params []ast.Parameter) *FunctionBuilder

SetParams establece los parámetros de la función

func (*FunctionBuilder) SetParamsFromNames added in v1.0.0

func (fb *FunctionBuilder) SetParamsFromNames(paramNames []string, paramTypes []*ast.Type) *FunctionBuilder

SetParamsFromNames establece los parámetros usando nombres y tipos

func (*FunctionBuilder) SetReturnType added in v1.0.0

func (fb *FunctionBuilder) SetReturnType(returnType *ast.Type) *FunctionBuilder

SetReturnType establece el tipo de retorno

type GenericInstance added in v1.0.0

type GenericInstance struct {
	BaseType string
	TypeArgs []string
	FullName string // e.g., "List<Int>"
}

GenericInstance represents an instantiated generic type

type GenericType added in v1.0.0

type GenericType = common.GenericType

GenericType represents a generic type parameter (like T, E, K, V in Java)

type GenericTypeBuilder added in v1.0.0

type GenericTypeBuilder struct {
	Type *ast.Type
	// contains filtered or unexported fields
}

type HintProvider

type HintProvider struct {
	// contains filtered or unexported fields
}

HintProvider generates hints based on error context

func NewHintProvider

func NewHintProvider(env *Env) *HintProvider

NewHintProvider creates a new hint provider

func (*HintProvider) GetHintForAttribute

func (hp *HintProvider) GetHintForAttribute(attrName string, typeName string) *ExceptionHint

GetHintForAttribute provides suggestions for missing attributes

func (*HintProvider) GetHintForEnumValue

func (hp *HintProvider) GetHintForEnumValue(enumName string, valueName string) *ExceptionHint

GetHintForEnumValue provides suggestions for enum value typos

func (*HintProvider) GetHintForUndefinedName

func (hp *HintProvider) GetHintForUndefinedName(name string) *ExceptionHint

GetHintForUndefinedName provides suggestions for undefined identifiers

func (*HintProvider) GetHintForUndefinedNameWithContext

func (hp *HintProvider) GetHintForUndefinedNameWithContext(name string, filepath string, line int) *ExceptionHint

GetHintForUndefinedNameWithContext provides suggestions with source file context

func (*HintProvider) GetHintForUndefinedNameWithEnv

func (hp *HintProvider) GetHintForUndefinedNameWithEnv(name string) *ExceptionHint

GetHintForUndefinedNameWithEnv provides suggestions using the env's code context

type HyException

type HyException struct {
	Message    string
	Type       string
	StackTrace []string
	Cause      *HyException
	Instance   any // The actual exception instance from Polyloft
	File       string
	Line       int
	Column     int
	Hint       *ExceptionHint
}

HyException represents a Polyloft exception

func NewHyException

func NewHyException(exceptionType, message string) *HyException

func (*HyException) Error

func (e *HyException) Error() string

func (*HyException) WithHint

func (e *HyException) WithHint(hint *ExceptionHint) *HyException

WithHint adds a hint to the exception

func (*HyException) WithLocation

func (e *HyException) WithLocation(file string, line, column int) *HyException

WithLocation adds location information to the exception

type InstanceCreator added in v1.1.0

type InstanceCreator func(env *common.Env, value any) (*ClassInstance, error)

InstanceCreator is a function that creates a ClassInstance from a native value

func GetInstanceCreator added in v1.1.0

func GetInstanceCreator(typeName string) (InstanceCreator, bool)

GetInstanceCreator returns the creator for a specific type

type InstanceCreatorRegistry added in v1.1.0

type InstanceCreatorRegistry struct {
	// contains filtered or unexported fields
}

InstanceCreatorRegistry holds all registered instance creators

type InterfaceBuilder added in v1.0.0

type InterfaceBuilder struct {
	Type *ast.Type
	// contains filtered or unexported fields
}

func NewInterfaceBuilder added in v1.0.0

func NewInterfaceBuilder(name string) *InterfaceBuilder

NewInterfaceBuilder crea un nuevo builder para interfaces

func (*InterfaceBuilder) AddDefaultMethod added in v1.0.0

func (ib *InterfaceBuilder) AddDefaultMethod(name string, returnType *ast.Type, params []ast.Parameter, body []ast.Stmt) *InterfaceBuilder

AddDefaultMethod agrega un método con implementación por defecto (supports overloading)

func (*InterfaceBuilder) AddMethod added in v1.0.0

func (ib *InterfaceBuilder) AddMethod(name string, returnType any, params []ast.Parameter) *InterfaceBuilder

AddMethod agrega un método a la interfaz (supports overloading)

func (*InterfaceBuilder) AddStaticField added in v1.0.0

func (ib *InterfaceBuilder) AddStaticField(name string, value any) *InterfaceBuilder

AddStaticField agrega un campo estático a la interfaz

func (*InterfaceBuilder) AddTypeParameters added in v1.1.0

func (ib *InterfaceBuilder) AddTypeParameters(typeParams []common.GenericType) *InterfaceBuilder

func (*InterfaceBuilder) Build added in v1.0.0

func (ib *InterfaceBuilder) Build(env *Env) (*InterfaceDefinition, error)

Build construye y registra la interfaz

func (*InterfaceBuilder) GetType added in v1.0.0

func (ib *InterfaceBuilder) GetType() *ast.Type

GetType returns the ast.Type reference for this interface builder

func (*InterfaceBuilder) SetSealed added in v1.0.0

func (ib *InterfaceBuilder) SetSealed(isSealed bool, permits []string) *InterfaceBuilder

SetSealed marca la interfaz como sealed

type InterfaceDefinition

type InterfaceDefinition = common.InterfaceDefinition

type LambdaTypeInstance added in v1.0.0

type LambdaTypeInstance struct {
	// contains filtered or unexported fields
}

LambdaTypeInstance represents a Lambda<P1, P2, ..., R>

type LanguagePattern

type LanguagePattern struct {
	Pattern     string
	Language    string
	HyLangEquiv string
	Description string
}

LanguagePattern represents a pattern from another language

type MethodInfo

type MethodInfo = common.MethodInfo

type MethodSignature

type MethodSignature = common.MethodSignature

type Options

type Options struct {
	Stdout io.Writer // where println/print write to
}

Options control execution behavior (flags, limits, debug hooks, etc.).

type Promise added in v1.0.0

type Promise struct {
	// contains filtered or unexported fields
}

Promise represents a JavaScript-style promise

type RecordBuilder added in v1.0.0

type RecordBuilder struct {
	Type *ast.Type
	// contains filtered or unexported fields
}

func NewRecordBuilder added in v1.0.0

func NewRecordBuilder(name string) *RecordBuilder

NewRecordBuilder crea un nuevo builder para records

func (*RecordBuilder) AddComponent added in v1.0.0

func (rb *RecordBuilder) AddComponent(name, componentType string) *RecordBuilder

AddComponent agrega un componente al record

func (*RecordBuilder) AddComponents added in v1.0.0

func (rb *RecordBuilder) AddComponents(components map[string]string) *RecordBuilder

AddComponents agrega múltiples componentes al record

func (*RecordBuilder) AddMethod added in v1.0.0

func (rb *RecordBuilder) AddMethod(name string, returnType *ast.Type, params []ast.Parameter, fn common.Func) *RecordBuilder

AddMethod agrega un método al record

func (*RecordBuilder) Build added in v1.0.0

func (rb *RecordBuilder) Build(env *Env) (*RecordDefinition, error)

Build construye y registra el record

type RecordComponent added in v1.0.0

type RecordComponent struct {
	Name string
	Type string
}

RecordComponent representa un componente de un record

type RecordDefinition added in v1.0.0

type RecordDefinition struct {
	Name        string
	Components  map[string]string
	Methods     map[string]MethodInfo
	AccessLevel string
	FileName    string
	PackageName string
}

RecordDefinition representa la definición de un record

type Thread

type Thread struct {
	// contains filtered or unexported fields
}

Thread represents a running thread

type TypeAlias added in v1.1.0

type TypeAlias struct {
	Name        string
	BaseType    string
	IsFinal     bool // if true, this is a nominal type (distinct from base type)
	PackageName string
}

TypeAlias represents a type alias definition

type TypeConversionError added in v1.1.0

type TypeConversionError struct {
	FromType string
	ToType   string
	Value    any
}

TypeConversionError represents an error during type conversion

func NewTypeConversionError added in v1.1.0

func NewTypeConversionError(fromType, toType string, value any) *TypeConversionError

NewTypeConversionError creates a new type conversion error

func (*TypeConversionError) Error added in v1.1.0

func (e *TypeConversionError) Error() string

type TypeConverter added in v1.1.0

type TypeConverter func(env *common.Env, value any) (any, bool)

TypeConverter is a function that converts a value to a specific type Returns the converted value and a boolean indicating success

func GetTypeConverter added in v1.1.0

func GetTypeConverter(typeName string) (TypeConverter, bool)

GetTypeConverter returns the converter for a specific type

type TypeRegistry added in v1.1.0

type TypeRegistry struct {
	// contains filtered or unexported fields
}

TypeRegistry holds all registered type converters

type WebSocketConnection added in v1.1.10

type WebSocketConnection struct {
	// contains filtered or unexported fields
}

WebSocketConnection represents a WebSocket connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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