SPVM::Compiler - Compiler
SPVM::Compiler is the Compiler class in the SPVM language. It compiles SPVM source codes and builds the runtime.
SPVM::Compiler
Compiler
The instance of the Runtime class is build by the "build_runtime" method in this class.
use Compiler; my $compiler = Compiler->new; $compiler->add_module_dir("lib"); $compiler->set_start_file(__FILE__); { my $class_name = "Foo"; $compiler->set_start_line(__LINE__ + 1); my $success = $compiler->compile($class_name); unless ($success) { my $error_messages = $compiler->get_error_messages; for my $error_message (@$error_messages) { warn "$error_message"; } die "Can't compile the \"$class_name\" class"; } } { my $class_name = "Bar"; $compiler->set_start_line(__LINE__ + 1); my $success = $compiler->compile($class_name); unless ($success) { my $error_messages = $compiler->get_error_messages; for my $error_message (@$error_messages) { warn "$error_message"; } die "Can't compile the \"$class_name\" class"; } } my $runtime = $compiler->build_runtime;
The Compiler class is a pointer class.
Its insntace has a pointer to a compiler object.
native static method new : Compiler ();
Creates a new Compiler object and returns it.
native method add_module_dir : void ($module_dir : string);
Adds a module directory to search for classes.
native method set_start_file : void ($start_file : string);
Sets the name of the file to start the compiling by the "compile" method.
native method set_start_line : void ($start_line : int);
Sets the line to start compiling by the "compile" method.
native method compile : int ($class_name : string);
Compiles the specified class and the classes that are load in the specified class.
Returns 1 on success, 0 on failure.
This method can be called multiple times.
native method get_error_messages : string[] ();
Returns compilation error messages in this compiling by the "compile" method.
native method build_runtime : Runtime ();
Builds the runtime and returns it.
The return value is a Runtime object.
Copyright 2023-2023 Yuki Kimoto, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.