DEVELOPERS NOTE
Tests
perl Makefile.PL
make
make test
Unit Tests
make && perl -Mblib t/default/convert.t
Cleanup
make clean
Create distribution
perl Makefile.PL
rm MANIFEST
make manifest
make disttest
make dist
SOLE TESTS
SPVM solo test command
# Normal run
yacc/bison.sh && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" && make -f solo/Makefile && ./solo/work/myexe foo bar
# Debug run
yacc/bison.sh && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_ALLOC_MEMORY_COUNT && make -f solo/Makefile && ./solo/work/myexe foo bar
# Debug run - Print AST, package information, operaion codes
yacc/bison.sh && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_DUMP --DEFINE=SPVM_DEBUG_ALLOC_MEMORY_COUNT && make -f solo/Makefile && ./solo/work/myexe foo bar
# Debug run - Print yacc result
yacc/bison.sh && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_YACC && make -f solo/Makefile && ./solo/work/myexe foo bar
# Cleanup
make -f solo/Makefile clean
# Normal run + show runtime info memory size
yacc/bison.sh && perl solo/solo_Makefile.PL --OPTIMIZE="-O0 -g" --DEFINE=SPVM_DEBUG_RUNTIME_INFO && make -f solo/Makefile && ./solo/work/myexe foo bar
See batcktrace of core dump
gdb solo/work/myexe core
bt
If core file is not output, set the following.
ulimit -c unlimited
PORTABILITY NOTE
SPVM is run on various environments.
Main compiler targets is gcc and clang.
Main OS targets is Linux/Unix, Windows/MinGW, macOS.
To keep maxmam portability in SPVM core, I have the following rule.
- don't use realloc.
- don't use global variables
- don't use inline keyword
- use -std=gnu99 always in core modules
- use fgetc instead of getc for FreeBSD compile error
- Don't use os error number(error.h defined values) outside of native subrsoutine.
- Don't contain os dependency features(for example unistd.h, windows.h)
- NOTE: In Windows/MinGW/Strawbery Perl, newline is always \x0A if mode is text mode
- Automatically loaded module must not be native or precompile
Currently, Byte, Short, Int, Long, Float, Double, Bool
- Don't use temporary directory in SPVM module, for example, using File::Temp.
Security risk is increased and, Windows dll file can't be removed by cleanuping temporary directory
- Don't use feature_test_macros, for example,
#define _XOPEN_SOURCE
#define _POSIX_SOURCE
#define _POSIX_C_SOURCE
CODING GUIDE LINE
- use int8_t, int16_t, int32_t, int64_t instead of byte, short, int, long, _Bool.
- char is used for only character.
- char[] is used for only string.
- constant value is defined by enum { } syntax.
- constant name is ,for example, SPVM_TYPE_C_FLAG_REF.
all character is upper case or under score. need _C_ between package name and constant base name
- fix all warnings before CPAN release
UTILITIES
Print config
# 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
Get all keywords
perl -n -e 'if (/strcmp\s*\(\s*symbol_name\s*,\s*"(.+?)"/) { print "$1\n" } ' lib/SPVM/Builder/src/spvm_toke.c
Get 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
Get SPVM::Builder module files
find lib | grep Builder | grep '\.pm' | perl -p -e 's|lib/||' | sort
Get SPVM source files
find lib | grep Builder | grep -P '\.c$' | perl -p -e 's|lib/SPVM/Builder/src/||' | sort
Get SPVM header files
find lib | grep Builder | grep -P '\.h$' | perl -p -e 's|lib/SPVM/Builder/include/||' | sort
Create compile error test module
spvmdist --genlib TestCase::CompileError::Foo t/default/lib
Create a SPVM distribution
spvmdist Foo