blib/lib/SPVM/Native/Runtime.pm untested

filter: Statementstmt n/a Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a SCAR -
1 package SPVM::Native::Runtime;
2  
3  
4  
5 1;
6  
7 =head1 Name
8  
9 SPVM::Native::Runtime - Native::Runtime
10  
11 =head1 Description
12  
13 C<SPVM::Native::Runtime> is C<Native::Runtime> class in L<SPVM> language.
14  
15 The instance has the runtime information such as operation codes, classes, methods, fields, class variables, constant strings.
16  
17 This class provides only the minimal methods to get the information of classes and methods.
18  
19 An instance of C<Native::Runtime> class is build by L<Native::Compiler#get_runtime|SPVM::Native::Compiler/"get_runtime">.
20  
21 =head1 Usage
22  
23 use Native::Runtime;
24
25 my $runtime = $compiler->get_runtime;
26
27 my $stack = $env->new_stack;
28  
29 =head1 Pointer
30  
31 The C<Native::Runtime> class is a L<pointer class|SPVM::Document::Language/"Pointer Class">.
32  
33 Its insntace has a pointer to a L<runtime|SPVM::Document::NativeAPI::Native::Runtime> object.
34  
35 =head1 Fields
36  
37 =head2 compiler
38  
39 C<has compiler : L<Native::Compiler|SPVM::Native::Compiler>;>
40  
41 The compiler that build this runtime.
42  
43 =head2 env
44  
45 C<has env : L<Native::Env|SPVM::Native::Env>;>
46  
47 The runtime environment owned by this runtime.
48  
49 =head1 Instance Methods
50  
51 =head2 get_basic_types_length
52  
53 C<method get_basic_types_length : int ();>
54  
55 Returns the length of the all basic types in the runtime.
56  
57 =head2 get_basic_type_by_id
58  
59 C<method get_basic_type_by_id : L<Native::BasicType|SPVM::Native::BasicType> ($id : int);>
60  
61 Returns a L<Native::BasicType|SPVM::Native::BasicType> object by a basic type ID.
62  
63 Exceptions:
64  
65 If The basic type cannot be found, an exception is throen.
66  
67 =head2 get_basic_type_by_name
68  
69 C<method get_basic_type_by_name : L<Native::BasicType|SPVM::Native::BasicType> ($name : string);>
70  
71 Returns a L<Native::BasicType|SPVM::Native::BasicType> object by a basic type name.
72  
73 Exceptions:
74  
75 If The basic type cannot be found, an exception is throen.
76  
77 =head2 build_precompile_class_source
78  
79 C<method build_precompile_class_source : string ($basic_type : L<Native::BasicType|SPVM::Native::BasicType>);>
80  
81 Builds the C source code of the class that contains C<precompile> methods and returns it.
82  
83 =head2 build_precompile_method_source
84  
85 C<method method build_precompile_method_source : string ($method : L<Native::Method|SPVM::Native::Method>);>
86  
87 Builds the C source code of a C<precompile> method and returns it.
88  
89 =head2 get_compiler
90  
91 C<method get_compiler : L<Native::Compiler|SPVM::Native::Compiler> ();>
92  
93 Gets the compiler that built this runtime.
94  
95 =head2 get_method_by_name
96  
97 C<method get_method_by_name : L<Native::Method|SPVM::Native::Method> ($class_name : string, $method_name : string);>
98  
99 Gets a method given the class name $class_name and the method name $method_name, returns it.
100  
101 =head2 get_field_by_name
102  
103 C<method get_field_by_name : L<Native::Field|SPVM::Native::Field> ($class_name : string, $field_name : string);>
104  
105 Gets a field given the class name $class_name and the method name $method_name, returns it.
106  
107 =head2 get_class_var_by_name
108  
109 C<method get_class_var_by_name : L<Native::ClassVar|SPVM::Native::ClassVar> ($class_name : string, $class_var_name : string);>
110  
111 Gets a class variable given the class name $class_name and the method name $method_name, returns it.
112  
113 =head2 get_basic_types
114  
115 C<method get_basic_types : L<Native::BasicType|SPVM::Native::BasicType>[] ($options : object[] = undef);>
116  
117 Returns basic types given the options $options.
118  
119 Options:
120  
121 Options $options is key-value pairs.
122  
123 =over 2
124  
125 =item * C<category> : int[]
126  
127 If the category ID of the basic type matches a value in this option values, only they are extracted.
128  
129 For constant values, see L<Basic Type Category IDs|SPVM::Native::Constant/"Basic Type Category IDs">.
130  
131 =item * C<is_anon> : Int
132  
133 If this option is a true value, only anon basic types are extracted.
134  
135 If this option is a false value, only non-anon basic types are extracted.
136  
137 =back
138  
139 =head2 get_env
140  
141 C<method get_env : L<Native::Env|SPVM::Native::Env> ();>
142  
143 Returns the L<"env"> field.
144  
145 =head1 See Also
146  
147 =over 2
148  
149 =item * L<Native::Compiler|SPVM::Native::Compiler>
150  
151 =item * L<Native::Env|SPVM::Native::Env>
152  
153 =back
154  
155 =head1 Copyright & License
156  
157 Copyright (c) 2023 Yuki Kimoto
158  
159 MIT License