Name

SPVM::Native::Runtime - Native::Runtime

Description

SPVM::Native::Runtime is the Native::Runtime class in the SPVM language.

The instance has the runtime information such as operation codes, classes, methods, fields, class variables, constant strings.

This class provides only the minimal methods to get the information of classes and methods.

An instance of the Native::Runtime class is build by Native::Compiler#get_runtime.

Usage

use Native::Runtime;

my $runtime = $compiler->get_runtime;

my $stack = $env->new_stack;

Pointer

The Native::Runtime class is a pointer class.

Its insntace has a pointer to a runtime object.

Fields

compiler

has compiler : Native::Compiler;

The compiler that build this runtime.

env

has env : Native::Env;

The runtime environment owned by this runtime.

Instance Methods

get_basic_types_length

method get_basic_types_length : int ();

Returns the length of the all basic types in the runtime.

get_basic_type_by_id

method get_basic_type_by_id : Native::BasicType ($id : int);

Returns a Native::BasicType object by a basic type ID.

Exceptions:

If The basic type cannot be found, an exception is throen.

get_basic_type_by_name

method get_basic_type_by_name : Native::BasicType ($name : string);

Returns a Native::BasicType object by a basic type name.

Exceptions:

If The basic type cannot be found, an exception is throen.

build_precompile_class_source

method build_precompile_class_source : string ($basic_type : Native::BasicType);

Builds the C source code of the class that contains precompile methods and returns it.

build_precompile_method_source

method method build_precompile_method_source : string ($method : Native::Method);

Builds the C source code of a precompile method and returns it.

get_compiler

method get_compiler : Native::Compiler ();

Gets the compiler that built this runtime.

get_method_by_name

method get_method_by_name : Native::Method ($class_name : string, $method_name : string);

Gets a method given the class name $class_name and the method name $method_name, returns it.

get_field_by_name

method get_field_by_name : Native::Field ($class_name : string, $field_name : string);

Gets a field given the class name $class_name and the method name $method_name, returns it.

get_class_var_by_name

method get_class_var_by_name : Native::ClassVar ($class_name : string, $class_var_name : string);

Gets a class variable given the class name $class_name and the method name $method_name, returns it.

get_basic_types

method get_basic_types : Native::BasicType[] ($options : object[] = undef);

Returns basic types given the options $options.

Options:

Options $options is key-value pairs.

  • category : int[]

    If the category ID of the basic type matches a value in this option values, only they are extracted.

    For constant values, see Basic Type Category IDs.

  • is_anon : Int

    If this option is a true value, only anon basic types are extracted.

    If this option is a false value, only non-anon basic types are extracted.

get_env

method get_env : Native::Env ();

Returns the "env" field.

See Also

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License