Developers Note

make

Tests

perl Makefile.PL
make
make test

Unit Tests

make && perl -Mblib t/02_vm/05_op/comparison_operator.t

Cleanup

make clean

Create MANIFEST

perl Makefile.PL
rm MANIFEST
make manifest

Create distribution

perl Makefile.PL
make disttest
make dist

Install SPVM

make install

Solo Tests

SPVM solo test command using spvm command

# Normal run
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules && make && perl -Mblib blib/script/spvm -I solo/lib/SPVM solo/script/myapp.spvm foo bar

# Debug run
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --optimize="-O0 -g" && make && perl -Mblib blib/script/spvm -I solo/lib/SPVM solo/script/myapp.spvm foo bar

# Debug run - Print memory count
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --optimize="-O0 -g" --define=SPVM_DEBUG_MEMORY && make && perl -Mblib blib/script/spvm -I solo/lib/SPVM solo/script/myapp.spvm foo bar

# Debug run - Print AST, package information, operaion codes
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --optimize="-O0 -g" --define=SPVM_DEBUG_COMPILE && make && perl -Mblib blib/script/spvm -I solo/lib/SPVM solo/script/myapp.spvm foo bar

# Debug run - Print yacc result
yacc/bison.sh && perl Makefile.PL --no-build-spvm-modules --define=SPVM_DEBUG_YACC --define=SPVM_DEBUG_COMPILE && make && perl -Mblib blib/script/spvm -I solo/lib/SPVM solo/script/myapp.spvm foo bar

SPVM solo test command using spvmcc command

# Normal run
make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp -f --no-config solo/script/myapp.spvm && ./solo/.spvm_build/work/myapp foo bar

# Debug run
make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp --optimize "-O0 -g" -f --no-config solo/script/myapp.spvm && ./solo/.spvm_build/work/myapp foo bar

# Debug run - Print memory count
make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp --define-spvm SPVM_DEBUG_MEMORY -f solo/script/myapp.spvm && ./solo/.spvm_build/work/myapp foo bar

# Debug run - Print memory count using config file
make && perl -Mblib blib/script/spvmcc -B solo/.spvm_build -I solo/lib/SPVM -o solo/.spvm_build/work/myapp --mode debug_memory_count -f solo/script/myapp.spvm && ./solo/.spvm_build/work/myapp foo bar

Cleanup

rm solo/.spvm_build/work/myapp

See batcktrace of core dump

# Compilation for debug
perl Makefile.PL --optimize="-O0 -g" && make

# Compiliation time stack trace
gdb perl core

# Runtime stack trace
gdb solo/.spvm_build/work/myapp core

bt

If core file is not output, set the following.

ulimit -c unlimited

Check memory with valgrind

valgrind --leak-check=full --track-origins=yes perl -Mblib t/02_vm/05_op/reference.t

Portability Note

SPVM is run on various environments. Main compiler targets is gcc, clang, MinGW. Main OS targets is Linux/Unix, Windows(MinGW), macOS. To keep maxmam portability in SPVM, I follow the following rule.

Coding Guide Line

Utilities

Gets SPVM Core Perl module files

find lib | grep -P '(Builder|BlessedObject|ExchangeAPI|Global|SPVM\.pm)' | grep '\.pm' | perl -p -e 's|lib/||' | sort

Gets SPVM header files

find lib | grep Builder | grep -P '\.h$' | perl -p -e 's|lib/SPVM/Builder/include/||' | sort

Gets SPVM source files

find lib | grep Builder | grep -P '\.c$' | perl -p -e 's|lib/SPVM/Builder/src/||' | sort

Gets SPVM Compilation and Rintime module files

find lib | grep -P '(Native\b)' | grep -P '\.(spvm|c)$' | perl -p -e 's|lib/||' | sort
# All config
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;'

# ivsize
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep ivsize

# myuname
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep myuname

# make
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep make

# dlext
perl -MConfig -MData::Dumper -e 'local $Data::Dumper::Sortkeys = 1; print Dumper \%Config;' | grep dlext

Gets all keywords

perl -n -e 'if (/strcmp\s*\(\s*symbol_name\s*,\s*"(.+?)"/) { print "$1\n" } ' lib/SPVM/Builder/src/spvm_toke.c

Gets the definition of syntax parsing

perl -n -e 'if (/^(%token|%type|%right|%nonassoc|%left|[a-zA-Z]|\s+:|\s+\|)(.+)/) { my $line = "$1$2"; if ($line =~ /^[a-zA-Z]/) { print "\n"; } print "$line\n" } ' yacc/spvm_yacc.y
find lib | grep -P '\.pm$' | grep -v 'lib/SPVM.pm$' | perl -p -e 's/\.pm$//' | sort | grep -v -P '^lib/SPVM(\.pm|/(Global|ExchangeAPI|Document|Builder|BlessedObject|Dist))' | perl -p -e 'chomp;s|lib/SPVM/||; s|/|::|g; $_ = "=item * L<SPVM::$_|SPVM::$_>\n\n";'

spvmdist

Creates a SPVM distribution

spvmdist --user-name="Yuki Kimoto" --user-email="kimoto.yuki@gmail.com"  Foo

Create only class files

spvmdist --version_from Foo --only-lib-files --user-name="Yuki Kimoto" --user-email="kimoto.yuki@gmail.com" Foo::Bar lib