Name

SPVM::Runtime - Runtime

Description

SPVM::Runtime is the 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 Runtime class is build by the build_runtime method in the Compiler class.

Usage

use Runtime;

my $runtime = $compiler->build_runtime;

my $basic_type_names = $runtime->get_basic_type_names;

my $method_names = $runtime->get_method_names("Foo");

my $stack = $env->new_stack;

Pointer

The Runtime class is a pointer class.

Its insntace has a pointer to a runtime object.

Instance Methods

get_basic_type_name

method get_basic_type_name : string[] ();

Gets the all basic type names in the runtime and returns it.

get_basic_type_parent_name

method get_basic_type_parent_name : string ($basic_type_name : string);

Gets the parent basic type name and returns it.

get_method_names

method get_method_names : string[] ($basic_type_name : string, $options : object[] = undef);

Gets method names and returns it.

Options:

The options are key-value pairs. The key is the string type.

  • native : Int

    Gets only native methods if this option is true.

  • precompile : Int

    Gets only precompile methods if this option is true.

  • enum : Int

    Get only enum methods if this option is true.

get_module_file

method get_module_file : string ($basic_type_name : string);

Gets the module file name and returns it.

build_precompile_module_source

method build_precompile_module_source : string ($basic_type_name : string);

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

get_basic_type_anon_basic_type_names

method get_basic_type_anon_basic_type_names : string[] ($basic_type_name : string);

Gets the anon basic type names and returns it.

get_method_is_class_method

method get_method_is_class_method : int ($basic_type_name : string, $method_name : string);

Checks if the method is a class method. If it is so, returns 1, otherwise returns 0.

build_precompile_method_source

method build_precompile_method_source : string ($basic_type_name : string, $method_name : string);

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

get_native_method_address

method get_native_method_address : Address ($basic_type_name : string, $method_name : string);

Gets the address of a native method and returns it.

The return type is the Address class.

set_native_method_address

method set_native_method_address : string ($basic_type_name : string, $method_name : string, $address : Address);

Sets the address of a native method.

The address is the Address class.

get_precompile_method_address

method get_precompile_method_address : Address ($basic_type_name : string, $method_name : string);

Gets the address of a precompile method and returns it.

The return type is the Address class.

set_precompile_method_address

method set_precompile_method_address : string ($basic_type_name : string, $method_name : string, $address : Address);

Sets the address of a precompile method.

The address is the Address class.

DESTROY

method DESTROY : void ();

The destructor.

See Also

Compiler

The build_runtime method in the Compiler class builds a rutnime.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License