Documentation
¶
Index ¶
- Constants
- Variables
- func ArrayToSlice(env *Env, arrayInstance *ClassInstance) ([]any, error)
- func AsBytes(env *common.Env, value any) ([]byte, bool)
- func BoolValue(v any) (bool, bool)
- func CallInstanceMethod(instance *ClassInstance, methodInfo MethodInfo, env *Env, args []any) (any, error)
- func ClassInstanceToArray(instance *ClassInstance) ([]any, error)
- func ClassInstanceToArrayTypeString(instance *ClassInstance) (string, error)
- func ConvertMapKey(env *Env, key any) any
- func ConvertMapValue(env *Env, value any) any
- func ConvertTo(env *common.Env, typeName string, value any) (any, bool)
- func ConvertToClassInstance(env *Env, value any) any
- func CreateBiFunctionInstance(lambda *ast.LambdaExpr, env *Env) (map[string]any, error)
- func CreateFunctionInstance(lambda *ast.LambdaExpr, env *Env) (map[string]any, error)
- func CreateGenericInstance(env *Env, value any) (any, error)
- func Eval(prog *ast.Program, opts Options) (any, error)
- func EvalWithContext(prog *ast.Program, opts Options, fileName, packageName string) (any, error)
- func EvalWithContextAndSource(prog *ast.Program, opts Options, fileName, packageName, source string) (any, error)
- func FastIntOperation(op int, a, b int) int
- func FloatValue(v any) (float64, bool)
- func FormatError(err error) string
- func FormatErrorPlain(err error) string
- func FormatErrorPlainWithContext(err error, codeContext []string, currentLine int) string
- func FormatErrorWithContext(err error, codeContext []string, currentLine int) string
- func GetCachedFloat(n float64) float64
- func GetCachedInt(n int) int
- func GetCachedString(s string) string
- func GetGenericValue(instance *ClassInstance) (any, error)
- func GetItemsFromCollection(env *Env, collection *ClassInstance) (any, error)
- func GetPooledEnv(parent *common.Env) *common.Env
- func GetTypeName(val any) string
- func InitFunctionInterfaces(env *Env) error
- func InitializeAnnotationBase(env *common.Env)
- func InitializeAnnotationInterfaces(env *common.Env)
- func InitializeBuiltinInstanceCreators()
- func InitializeBuiltinTypeConverters()
- func InstallArrayBuiltin(env *Env) error
- func InstallAsyncAwait(env *common.Env)
- func InstallBoolBuiltin(env *Env) error
- func InstallBytesBuiltin(env *Env) error
- func InstallChannelBuiltin(env *Env) error
- func InstallCollectionInterface(env *Env) error
- func InstallCryptoModule(env *Env, opts Options) error
- func InstallDequeBuiltin(env *Env) error
- func InstallExceptionBuiltins(env *Env)
- func InstallGenericBuiltin(env *Env) error
- func InstallGenerics(env *common.Env)
- func InstallHttpModule(env *Env, opts Options)
- func InstallIOModule(env *Env, opts Options) error
- func InstallIndexableInterface(env *Env) error
- func InstallIterableInterface(env *Env) error
- func InstallListBuiltin(env *Env) error
- func InstallMapBuiltin(env *Env) error
- func InstallMathModule(env *Env)
- func InstallNetModule(env *Env, opts Options)
- func InstallNumberBuiltin(env *Env) error
- func InstallPairBuiltin(env *Env) error
- func InstallRangeBuiltin(env *Env) error
- func InstallSerializableInterface(env *Env) error
- func InstallSetBuiltin(env *Env) error
- func InstallSliceableInterface(env *Env) error
- func InstallSocketsModule(env *Env, opts Options) error
- func InstallStringBuiltin(env *Env) error
- func InstallSysModule(env *Env, opts Options)
- func InstallTupleClass(env *Env) error
- func InstallUnstructuredInterface(env *Env) error
- func IntValue(v any) (int, bool)
- func IsBiFunction(val any) bool
- func IsClassInstanceOfDefinition(instance *common.ClassInstance, class *common.ClassDefinition) bool
- func IsFunction(val any) bool
- func IsInstanceOf(value any, typeName string) bool
- func IsTerminal() bool
- func MapToClassMap(mapInstance *ClassInstance) (map[*ClassInstance]*ClassInstance, error)
- func MapToData(env *Env, value any) (map[string]any, bool)
- func MapToObject(env *Env, mapInstance *ClassInstance) (map[string]any, error)
- func RegisterInstanceCreator(typeName string, creator InstanceCreator)
- func RegisterTypeConverter(typeName string, converter TypeConverter)
- func ReleaseEnv(env *common.Env)
- func ResetGlobalRegistries()
- func SortSuggestionsByRelevance(suggestions []string, target string) []string
- func StringValue(v any) string
- func ThrowAccessError(env *Env, memberName string, containerName string, accessLevel string) error
- func ThrowArityError(env *Env, expected, got int) error
- func ThrowAttributeError(env *Env, attrName string, typeName string) error
- func ThrowAttributeErrorWithHint(env *Env, attrName string, typeName string, availableMethods []string) error
- func ThrowConversionError(env *Env, value any, targetType string) error
- func ThrowIndexError(env *Env, index, size int, collectionType string) error
- func ThrowInitializationError(env *Env, what string) error
- func ThrowNameError(env *Env, name string) error
- func ThrowNotCallableError(env *Env, objectType string, value string) error
- func ThrowNotImplementedError(env *Env, feature string) error
- func ThrowRuntimeError(env *Env, message string) error
- func ThrowStateError(env *Env, message string) error
- func ThrowTypeError(env *Env, expected string, got ...any) error
- func ThrowValueError(env *Env, message string) error
- func ValidateArgumentType(value any, expectedType string) error
- func ValidateFunctionArguments(args []any, paramTypes []string, hasVariadic bool, variadicType string) ([]any, error)
- func ValidateVariadicArguments(args []any, expectedType string) ([]any, error)
- func WrapLambdaAsFunction(lambda *ast.LambdaExpr, env *Env) (common.Func, error)
- type AnnotationInstance
- type ClassBuilder
- func (cb *ClassBuilder) AddAlias(alias string) *ClassBuilder
- func (cb *ClassBuilder) AddBuiltinConstructor(params []ast.Parameter, fn common.Func) *ClassBuilder
- func (cb *ClassBuilder) AddBuiltinMethod(name string, returnType *ast.Type, params []ast.Parameter, fn common.Func, ...) *ClassBuilder
- func (cb *ClassBuilder) AddConstructor(params []ast.Parameter, body []ast.Stmt) *ClassBuilder
- func (cb *ClassBuilder) AddField(name string, fieldType *ast.Type, modifiers []string) *ClassBuilder
- func (cb *ClassBuilder) AddInterface(interfaceDef *common.InterfaceDefinition) *ClassBuilder
- func (cb *ClassBuilder) AddMethod(name string, returnType *ast.Type, params []ast.Parameter, body []ast.Stmt, ...) *ClassBuilder
- func (cb *ClassBuilder) AddMethodWithParams(name string, returnType *ast.Type, paramNames []string, paramTypes []*ast.Type, ...) *ClassBuilder
- func (cb *ClassBuilder) AddSimpleMethod(name string, returnType *ast.Type, fn common.Func) *ClassBuilder
- func (cb *ClassBuilder) AddStaticField(name string, value any) *ClassBuilder
- func (cb *ClassBuilder) AddStaticMethod(name string, returnType *ast.Type, params []ast.Parameter, fn common.Func) *ClassBuilder
- func (cb *ClassBuilder) AddTypeParameters(typeParams []common.GenericType) *ClassBuilder
- func (cb *ClassBuilder) Build(env *Env) (*ClassDefinition, error)
- func (cb *ClassBuilder) BuildAndGet(env *Env) (*ClassDefinition, common.Func, error)
- func (cb *ClassBuilder) BuildStatic(env *Env) (*ClassDefinition, error)
- func (cb *ClassBuilder) GetType() *ast.Type
- func (cb *ClassBuilder) SetAbstract(isAbstract bool) *ClassBuilder
- func (cb *ClassBuilder) SetBuiltinConstructor(params []ast.Parameter, fn common.Func) *ClassBuilder
- func (cb *ClassBuilder) SetConstructor(params []ast.Parameter, body []ast.Stmt) *ClassBuilder
- func (cb *ClassBuilder) SetParent(parent *ClassDefinition) *ClassBuilder
- type ClassDefinition
- type ClassInstance
- func CreateArrayInstance(env *Env, items []any) (*ClassInstance, error)
- func CreateBoolInstance(env *Env, value bool) (*ClassInstance, error)
- func CreateBytesInstance(env *common.Env, data any) (*ClassInstance, error)
- func CreateFloatInstance(env *Env, value float64) (*ClassInstance, error)
- func CreateInstanceFor(env *common.Env, typeName string, value any) (*ClassInstance, error)
- func CreateIntInstance(env *Env, value int) (*ClassInstance, error)
- func CreateMapInstance(env *Env, data any) (*ClassInstance, error)
- func CreateRangeInstance(env *Env, start, end int, step ...int) (*ClassInstance, error)
- func CreateStringInstance(env *Env, value string) (*ClassInstance, error)
- func GetClassInstance(val any) (*ClassInstance, bool)
- type CompletableFuture
- type ConstructorInfo
- type EnumBuilder
- type EnumValue
- type Env
- type ExceptionHint
- type FieldInfo
- type Func
- type FunctionBuilder
- func (fb *FunctionBuilder) Build(env *Env) (common.Func, error)
- func (fb *FunctionBuilder) SetAccessLevel(accessLevel string) *FunctionBuilder
- func (fb *FunctionBuilder) SetImplementation(impl common.Func) *FunctionBuilder
- func (fb *FunctionBuilder) SetParams(params []ast.Parameter) *FunctionBuilder
- func (fb *FunctionBuilder) SetParamsFromNames(paramNames []string, paramTypes []*ast.Type) *FunctionBuilder
- func (fb *FunctionBuilder) SetReturnType(returnType *ast.Type) *FunctionBuilder
- type GenericInstance
- type GenericType
- type GenericTypeBuilder
- type HintProvider
- func (hp *HintProvider) GetHintForAttribute(attrName string, typeName string) *ExceptionHint
- func (hp *HintProvider) GetHintForEnumValue(enumName string, valueName string) *ExceptionHint
- func (hp *HintProvider) GetHintForUndefinedName(name string) *ExceptionHint
- func (hp *HintProvider) GetHintForUndefinedNameWithContext(name string, filepath string, line int) *ExceptionHint
- func (hp *HintProvider) GetHintForUndefinedNameWithEnv(name string) *ExceptionHint
- type HyException
- type InstanceCreator
- type InstanceCreatorRegistry
- type InterfaceBuilder
- func (ib *InterfaceBuilder) AddDefaultMethod(name string, returnType *ast.Type, params []ast.Parameter, body []ast.Stmt) *InterfaceBuilder
- func (ib *InterfaceBuilder) AddMethod(name string, returnType any, params []ast.Parameter) *InterfaceBuilder
- func (ib *InterfaceBuilder) AddStaticField(name string, value any) *InterfaceBuilder
- func (ib *InterfaceBuilder) AddTypeParameters(typeParams []common.GenericType) *InterfaceBuilder
- func (ib *InterfaceBuilder) Build(env *Env) (*InterfaceDefinition, error)
- func (ib *InterfaceBuilder) GetType() *ast.Type
- func (ib *InterfaceBuilder) SetSealed(isSealed bool, permits []string) *InterfaceBuilder
- type InterfaceDefinition
- type LambdaTypeInstance
- type LanguagePattern
- type MethodInfo
- type MethodSignature
- type Options
- type Promise
- type RecordBuilder
- func (rb *RecordBuilder) AddComponent(name, componentType string) *RecordBuilder
- func (rb *RecordBuilder) AddComponents(components map[string]string) *RecordBuilder
- func (rb *RecordBuilder) AddMethod(name string, returnType *ast.Type, params []ast.Parameter, fn common.Func) *RecordBuilder
- func (rb *RecordBuilder) Build(env *Env) (*RecordDefinition, error)
- type RecordComponent
- type RecordDefinition
- type Thread
- type TypeAlias
- type TypeConversionError
- type TypeConverter
- type TypeRegistry
- type WebSocketConnection
Constants ¶
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 ¶
var NewEnv = common.NewEnv
Use common definitions for Env and Func
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 BoolValue ¶ added in v1.0.0
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
ConvertMapKey converts a key to the appropriate type for use in a Map
func ConvertMapValue ¶ added in v1.1.0
ConvertMapValue converts a value to the appropriate type for storage in a Map
func ConvertTo ¶ added in v1.1.0
ConvertTo attempts to convert a value to the specified type using registered converters
func ConvertToClassInstance ¶ added in v1.1.0
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
CreateBiFunctionInstance creates an instance of BiFunction interface from a lambda
func CreateFunctionInstance ¶ added in v1.0.0
CreateFunctionInstance creates an instance of Function interface from a lambda
func CreateGenericInstance ¶ added in v1.0.0
CreateGenericInstance creates a Generic instance wrapping a native Go value
func EvalWithContext ¶
func FastIntOperation ¶ added in v1.1.4
FastIntOperation performs optimized integer arithmetic
func FloatValue ¶ added in v1.0.0
FloatValue extracts the Go float64 value from a Float instance or converts a value to float64
func FormatError ¶
FormatError formats a HyException with colors and hints
func FormatErrorPlain ¶
FormatErrorPlain formats an error without colors (for non-terminal output)
func FormatErrorPlainWithContext ¶
FormatErrorPlainWithContext formats an error without colors but with code context
func FormatErrorWithContext ¶
FormatErrorWithContext formats a HyException with code context if available
func GetCachedFloat ¶ added in v1.0.0
GetCachedFloat returns a cached float for common values
func GetCachedInt ¶ added in v1.0.0
GetCachedInt returns a cached integer for small values
func GetCachedString ¶ added in v1.0.0
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
GetPooledEnv gets an environment from the pool and initializes it
func GetTypeName ¶ added in v1.1.0
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
InitFunctionInterfaces initializes the Function and BiFunction interfaces
func InitializeAnnotationBase ¶ added in v0.2.0
InitializeAnnotationBase registers the base Annotation class
func InitializeAnnotationInterfaces ¶ added in v0.2.0
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
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
InstallAsyncAwait sets up async/await support in the environment using ClassBuilder
func InstallBoolBuiltin ¶ added in v1.0.0
InstallBoolBuiltin installs Bool builtin type as a class
func InstallBytesBuiltin ¶ added in v1.1.0
InstallBytesBuiltin installs the Bytes builtin class for handling byte arrays
func InstallChannelBuiltin ¶ added in v1.0.0
InstallChannelBuiltin creates the builtin Channel class
func InstallCollectionInterface ¶ added in v1.1.0
func InstallCryptoModule ¶
InstallCryptoModule installs the complete Crypto module with cryptographic functions
func InstallDequeBuiltin ¶ added in v1.0.0
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
InstallGenericBuiltin installs the Generic builtin type Generic wraps any native Go value and provides conversion methods
func InstallGenerics ¶ added in v1.0.0
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
InstallHttpModule installs the HTTP module using the builder pattern
func InstallIOModule ¶
func InstallIndexableInterface ¶ added in v1.1.0
func InstallIterableInterface ¶ added in v1.0.0
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
InstallListBuiltin installs the List<T> builtin class
func InstallMapBuiltin ¶ added in v1.0.0
func InstallMathModule ¶
func InstallMathModule(env *Env)
InstallMathModule installs the Math module with all mathematical functions
func InstallNetModule ¶
InstallNetModule installs the complete Net module with networking functions
func InstallNumberBuiltin ¶ added in v1.0.0
InstallNumberBuiltin installs Int and Float builtin types as classes
func InstallPairBuiltin ¶ added in v1.0.0
InstallPairBuiltin creates the Pair<K,V> class for key-value pairs (formerly MapEntry)
func InstallRangeBuiltin ¶ added in v1.0.0
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 InstallSetBuiltin ¶ added in v1.0.0
InstallSetBuiltin installs the Set<T> builtin class
func InstallSliceableInterface ¶ added in v1.1.0
func InstallSocketsModule ¶ added in v1.1.0
InstallSocketsModule installs Socket classes for network communication
func InstallStringBuiltin ¶ added in v1.0.0
InstallStringBuiltin installs String builtin type as a class
func InstallSysModule ¶
InstallSysModule installs the complete Sys module with all functions
func InstallTupleClass ¶ added in v1.0.0
InstallTupleClass installs the Tuple builtin class Tuple is an immutable sequence that implements Unstructured interface
func InstallUnstructuredInterface ¶ added in v1.0.0
func IntValue ¶ added in v1.0.0
IntValue extracts the Go int value from an Integer instance or converts a value to int
func IsBiFunction ¶ added in v1.0.0
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
IsFunction checks if a value implements the Function interface
func IsInstanceOf ¶
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
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
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 ¶
SortSuggestionsByRelevance sorts suggestions by their similarity to the target
func StringValue ¶ added in v1.0.0
StringValue extracts the Go string value from a String instance or converts a value to string
func ThrowAccessError ¶
ThrowAccessError throws an error when trying to access private/protected members
func ThrowArityError ¶
ThrowArityError throws an ArityError exception
func ThrowAttributeError ¶
ThrowAttributeError throws an AttributeError exception for missing attributes/fields
func ThrowAttributeErrorWithHint ¶ added in v1.0.0
func ThrowConversionError ¶ added in v1.0.0
ThrowConversionError throws a ConversionError exception for type conversion failures
func ThrowIndexError ¶ added in v1.0.0
ThrowIndexError throws an IndexError exception for out-of-bounds access
func ThrowInitializationError ¶ added in v1.0.0
ThrowInitializationError throws an InitializationError exception
func ThrowNameError ¶
ThrowNameError throws a NameError exception for undefined names/identifiers
func ThrowNotCallableError ¶
ThrowNotCallableError throws an error when trying to call a non-callable object
func ThrowNotImplementedError ¶
ThrowNotImplementedError throws an error for unimplemented features
func ThrowRuntimeError ¶
ThrowRuntimeError throws a RuntimeError exception Position information (file, line, column) is automatically retrieved from env
func ThrowStateError ¶ added in v1.0.0
ThrowStateError throws a StateError exception for invalid state operations
func ThrowTypeError ¶
ThrowTypeError throws a TypeError exception Position information (file, line, column) is automatically retrieved from env
func ThrowValueError ¶
ThrowValueError throws a ValueError exception for invalid values
func ValidateArgumentType ¶ added in v1.0.0
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
ValidateVariadicArguments validates variadic arguments and converts them to an array
func WrapLambdaAsFunction ¶ added in v1.0.0
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 ¶
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
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
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
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 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 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
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 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
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
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
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
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
Source Files
¶
- annotation_base.go
- annotation_interfaces.go
- async_await.go
- builder.go
- builtin_array.go
- builtin_bool.go
- builtin_bytes.go
- builtin_deque.go
- builtin_generic.go
- builtin_iterable.go
- builtin_list.go
- builtin_map.go
- builtin_number.go
- builtin_range.go
- builtin_set.go
- builtin_string.go
- builtin_tuple.go
- channels.go
- class.go
- crypto.go
- engine.go
- enum.go
- error_formatter.go
- exception_hints.go
- exceptions.go
- expressions.go
- function_interface.go
- generics.go
- http.go
- io.go
- math.go
- net.go
- pools.go
- record.go
- sockets.go
- switch.go
- sys.go
- type_converter.go
- typecheck.go