├── Doxyfile ├── LICENSE ├── Makefile ├── README ├── SConstruct ├── docs ├── COPYING ├── img │ └── BuildOverview.png └── src │ ├── AssertStatement.txt │ ├── BuildOverview.odg │ ├── BuildSystem.txt │ ├── ClassesDesign.txt │ ├── Closures.txt │ ├── DevelopmentProcess.txt │ ├── ErrorsAndExceptions.txt │ ├── FrequentlyAskedQuestions.txt │ ├── GeneratorDesign.txt │ ├── HeapDesign.txt │ ├── HowToPortPyMite.txt │ ├── HowToProgramTheAt91sam7s64-ek.txt │ ├── HowToReleasePyMite.txt │ ├── HowToUsePyMite.txt │ ├── InteractivePyMite.txt │ ├── Makefile │ ├── ModuleImages.txt │ ├── P14pOverview.txt │ ├── PyMiteFeatures.txt │ ├── StringObjects.txt │ ├── Testing.txt │ ├── doxygen_mainpage.h │ └── index.txt └── src ├── lib ├── COPYING ├── __bi.py ├── avr.py ├── dict.py ├── func.py ├── ipm.py ├── list.py ├── sizeof.py ├── string.py └── sys.py ├── platform ├── COPYING ├── _unmaintained │ └── mmb103 │ │ ├── Makefile │ │ ├── README │ │ ├── SConscript │ │ ├── libmmb103.a │ │ ├── libmmb103.h │ │ ├── main.c │ │ ├── main.py │ │ ├── mmb.py │ │ ├── plat.c │ │ └── pmfeatures.h ├── arduino_mega │ ├── Makefile │ ├── README │ ├── main.c │ ├── main.py │ ├── plat.c │ ├── plat.h │ └── pmfeatures.py ├── at91sam7s-ek │ ├── AT91SAM7S64-RAM.ld │ ├── AT91SAM7S64-ROM.ld │ ├── AT91SAM7S64.h │ ├── Board.h │ ├── Cstartup.S │ ├── Cstartup_SAM7.c │ ├── Makefile │ ├── README │ ├── SConscript │ ├── lib_AT91SAM7S64.h │ ├── main.c │ ├── main.py │ ├── plat.c │ ├── plat.h │ └── pmfeatures.py ├── avr │ ├── Makefile │ ├── README │ ├── SConscript │ ├── main.c │ ├── main.py │ ├── plat.c │ ├── plat.h │ └── pmfeatures.py ├── desktop │ ├── Makefile │ ├── README │ ├── SConscript │ ├── main.c │ ├── main.py │ ├── plat.c │ ├── plat.h │ └── pmfeatures.py ├── econotag │ ├── Makefile │ ├── README │ ├── econotag.py │ ├── main.c │ ├── main.py │ ├── patch_bi.patch │ ├── patch_libmc1322x_types.patch │ ├── plat.c │ ├── plat.h │ ├── pmfeatures.py │ ├── red-bsl.py │ └── syscalls.c ├── mbed │ ├── Makefile │ ├── README │ ├── TextLCD.lib │ ├── main.cpp │ ├── main.py │ ├── mbed.lib │ ├── mbed.py │ ├── plat.cpp │ ├── plat.h │ └── pmfeatures.py ├── mosync │ ├── Makefile │ ├── README │ ├── ma.py │ ├── ma_gen.py │ ├── main.c │ ├── main.py │ ├── p14p.png │ ├── plat.c │ ├── plat.h │ ├── pmfeatures.py │ └── resources.lst ├── pic24 │ ├── Makefile │ ├── README │ ├── common │ │ ├── dataXfer.c │ │ ├── dataXferImpl.c │ │ ├── pic24_adc.c │ │ ├── pic24_clockfreq.c │ │ ├── pic24_configbits.c │ │ ├── pic24_ecan.c │ │ ├── pic24_flash.c │ │ ├── pic24_i2c.c │ │ ├── pic24_pyports.c │ │ ├── pic24_serial.c │ │ ├── pic24_spi.c │ │ ├── pic24_stdio_uart.c │ │ ├── pic24_timer.c │ │ ├── pic24_uart.c │ │ ├── pic24_util.c │ │ └── readme.txt │ ├── crlf.py │ ├── fixcrlf │ ├── heapsize.h │ ├── include │ │ ├── dataXfer.h │ │ ├── dataXferImpl.h │ │ ├── devices │ │ │ ├── PIC24FJ128GA006_ports.h │ │ │ ├── dev.txt │ │ │ ├── dev33.txt │ │ │ ├── dspic33fj128gp202_ports.h │ │ │ ├── dspic33fj128gp202_pyports.h │ │ │ ├── dspic33fj128gp204_ports.h │ │ │ ├── dspic33fj128gp204_pyports.h │ │ │ ├── dspic33fj128gp802_ports.h │ │ │ ├── dspic33fj128gp802_pyports.h │ │ │ ├── dspic33fj128gp804_ports.h │ │ │ ├── dspic33fj128gp804_pyports.h │ │ │ ├── dspic33fj12gp201_ports.h │ │ │ ├── dspic33fj12gp201_pyports.h │ │ │ ├── dspic33fj12gp202_ports.h │ │ │ ├── dspic33fj12gp202_pyports.h │ │ │ ├── dspic33fj16gp304_ports.h │ │ │ ├── dspic33fj16gp304_pyports.h │ │ │ ├── dspic33fj32gp202_ports.h │ │ │ ├── dspic33fj32gp202_pyports.h │ │ │ ├── dspic33fj32gp204_ports.h │ │ │ ├── dspic33fj32gp204_pyports.h │ │ │ ├── dspic33fj32gp302_ports.h │ │ │ ├── dspic33fj32gp302_pyports.h │ │ │ ├── dspic33fj32gp304_ports.h │ │ │ ├── dspic33fj32gp304_pyports.h │ │ │ ├── dspic33fj64gp202_ports.h │ │ │ ├── dspic33fj64gp202_pyports.h │ │ │ ├── dspic33fj64gp204_ports.h │ │ │ ├── dspic33fj64gp204_pyports.h │ │ │ ├── dspic33fj64gp802_ports.h │ │ │ ├── dspic33fj64gp802_pyports.h │ │ │ ├── dspic33fj64gp804_ports.h │ │ │ ├── dspic33fj64gp804_pyports.h │ │ │ ├── gen_ports_h.pl │ │ │ ├── get_devices.pl │ │ │ ├── parse_pickit2_data.pl │ │ │ ├── pic24_deviceids.xlsx │ │ │ ├── pic24dev_data.pl │ │ │ ├── pic24f16ka102_ports.h │ │ │ ├── pic24f16ka102_pyports.h │ │ │ ├── pic24fj128ga006_pyports.h │ │ │ ├── pic24fj128ga008_ports.h │ │ │ ├── pic24fj128ga008_pyports.h │ │ │ ├── pic24fj128ga010_ports.h │ │ │ ├── pic24fj128ga010_pyports.h │ │ │ ├── pic24fj128ga106_ports.h │ │ │ ├── pic24fj128ga106_pyports.h │ │ │ ├── pic24fj128ga108_ports.h │ │ │ ├── pic24fj128ga108_pyports.h │ │ │ ├── pic24fj128ga110_ports.h │ │ │ ├── pic24fj128ga110_pyports.h │ │ │ ├── pic24fj128gb106_ports.h │ │ │ ├── pic24fj128gb106_pyports.h │ │ │ ├── pic24fj128gb108_ports.h │ │ │ ├── pic24fj128gb108_pyports.h │ │ │ ├── pic24fj128gb110_ports.h │ │ │ ├── pic24fj128gb110_pyports.h │ │ │ ├── pic24fj16ga002_ports.h │ │ │ ├── pic24fj16ga002_pyports.h │ │ │ ├── pic24fj16ga004_ports.h │ │ │ ├── pic24fj16ga004_pyports.h │ │ │ ├── pic24fj192ga106_ports.h │ │ │ ├── pic24fj192ga106_pyports.h │ │ │ ├── pic24fj192ga108_ports.h │ │ │ ├── pic24fj192ga108_pyports.h │ │ │ ├── pic24fj192ga110_ports.h │ │ │ ├── pic24fj192ga110_pyports.h │ │ │ ├── pic24fj192gb106_ports.h │ │ │ ├── pic24fj192gb106_pyports.h │ │ │ ├── pic24fj192gb108_ports.h │ │ │ ├── pic24fj192gb108_pyports.h │ │ │ ├── pic24fj192gb110_ports.h │ │ │ ├── pic24fj192gb110_pyports.h │ │ │ ├── pic24fj256ga106_ports.h │ │ │ ├── pic24fj256ga106_pyports.h │ │ │ ├── pic24fj256ga108_ports.h │ │ │ ├── pic24fj256ga108_pyports.h │ │ │ ├── pic24fj256ga110_ports.h │ │ │ ├── pic24fj256ga110_pyports.h │ │ │ ├── pic24fj256gb106_ports.h │ │ │ ├── pic24fj256gb106_pyports.h │ │ │ ├── pic24fj256gb108_ports.h │ │ │ ├── pic24fj256gb108_pyports.h │ │ │ ├── pic24fj256gb110_ports.h │ │ │ ├── pic24fj256gb110_pyports.h │ │ │ ├── pic24fj32ga002_ports.h │ │ │ ├── pic24fj32ga002_pyports.h │ │ │ ├── pic24fj32ga004_ports.h │ │ │ ├── pic24fj32ga004_pyports.h │ │ │ ├── pic24fj32ga102_ports.h │ │ │ ├── pic24fj32ga104_ports.h │ │ │ ├── pic24fj32gb002_ports.h │ │ │ ├── pic24fj32gb002_pyports.h │ │ │ ├── pic24fj32gb004_ports.h │ │ │ ├── pic24fj32gb004_pyports.h │ │ │ ├── pic24fj48ga002_ports.h │ │ │ ├── pic24fj48ga002_pyports.h │ │ │ ├── pic24fj48ga004_ports.h │ │ │ ├── pic24fj48ga004_pyports.h │ │ │ ├── pic24fj64ga002_ports.h │ │ │ ├── pic24fj64ga002_pyports.h │ │ │ ├── pic24fj64ga004_ports.h │ │ │ ├── pic24fj64ga004_pyports.h │ │ │ ├── pic24fj64ga006_ports.h │ │ │ ├── pic24fj64ga006_pyports.h │ │ │ ├── pic24fj64ga008_ports.h │ │ │ ├── pic24fj64ga008_pyports.h │ │ │ ├── pic24fj64ga010_ports.h │ │ │ ├── pic24fj64ga010_pyports.h │ │ │ ├── pic24fj64ga102_ports.h │ │ │ ├── pic24fj64ga104_ports.h │ │ │ ├── pic24fj64gb002_ports.h │ │ │ ├── pic24fj64gb002_pyports.h │ │ │ ├── pic24fj64gb004_ports.h │ │ │ ├── pic24fj64gb004_pyports.h │ │ │ ├── pic24fj64gb106_ports.h │ │ │ ├── pic24fj64gb106_pyports.h │ │ │ ├── pic24fj64gb108_ports.h │ │ │ ├── pic24fj64gb108_pyports.h │ │ │ ├── pic24fj64gb110_ports.h │ │ │ ├── pic24fj64gb110_pyports.h │ │ │ ├── pic24fj96ga006_ports.h │ │ │ ├── pic24fj96ga006_pyports.h │ │ │ ├── pic24fj96ga008_ports.h │ │ │ ├── pic24fj96ga008_pyports.h │ │ │ ├── pic24fj96ga010_ports.h │ │ │ ├── pic24fj96ga010_pyports.h │ │ │ ├── pic24hj128gp202_ports.h │ │ │ ├── pic24hj128gp202_pyports.h │ │ │ ├── pic24hj128gp204_ports.h │ │ │ ├── pic24hj128gp204_pyports.h │ │ │ ├── pic24hj128gp206_ports.h │ │ │ ├── pic24hj128gp206_pyports.h │ │ │ ├── pic24hj128gp210_ports.h │ │ │ ├── pic24hj128gp210_pyports.h │ │ │ ├── pic24hj128gp306_ports.h │ │ │ ├── pic24hj128gp306_pyports.h │ │ │ ├── pic24hj128gp310_ports.h │ │ │ ├── pic24hj128gp310_pyports.h │ │ │ ├── pic24hj128gp502_ports.h │ │ │ ├── pic24hj128gp502_pyports.h │ │ │ ├── pic24hj128gp504_ports.h │ │ │ ├── pic24hj128gp504_pyports.h │ │ │ ├── pic24hj128gp506_ports.h │ │ │ ├── pic24hj128gp506_pyports.h │ │ │ ├── pic24hj128gp510_ports.h │ │ │ ├── pic24hj128gp510_pyports.h │ │ │ ├── pic24hj12gp201_ports.h │ │ │ ├── pic24hj12gp201_pyports.h │ │ │ ├── pic24hj12gp202_ports.h │ │ │ ├── pic24hj12gp202_pyports.h │ │ │ ├── pic24hj16gp304_ports.h │ │ │ ├── pic24hj16gp304_pyports.h │ │ │ ├── pic24hj256gp206_ports.h │ │ │ ├── pic24hj256gp206_pyports.h │ │ │ ├── pic24hj256gp210_ports.h │ │ │ ├── pic24hj256gp210_pyports.h │ │ │ ├── pic24hj256gp610_ports.h │ │ │ ├── pic24hj256gp610_pyports.h │ │ │ ├── pic24hj32gp202_ports.h │ │ │ ├── pic24hj32gp202_pyports.h │ │ │ ├── pic24hj32gp204_ports.h │ │ │ ├── pic24hj32gp204_pyports.h │ │ │ ├── pic24hj32gp302_ports.h │ │ │ ├── pic24hj32gp302_pyports.h │ │ │ ├── pic24hj32gp304_ports.h │ │ │ ├── pic24hj32gp304_pyports.h │ │ │ ├── pic24hj64gp202_ports.h │ │ │ ├── pic24hj64gp202_pyports.h │ │ │ ├── pic24hj64gp204_ports.h │ │ │ ├── pic24hj64gp204_pyports.h │ │ │ ├── pic24hj64gp206_ports.h │ │ │ ├── pic24hj64gp206_pyports.h │ │ │ ├── pic24hj64gp210_ports.h │ │ │ ├── pic24hj64gp210_pyports.h │ │ │ ├── pic24hj64gp502_ports.h │ │ │ ├── pic24hj64gp502_pyports.h │ │ │ ├── pic24hj64gp504_ports.h │ │ │ ├── pic24hj64gp504_pyports.h │ │ │ ├── pic24hj64gp506_ports.h │ │ │ ├── pic24hj64gp506_pyports.h │ │ │ ├── pic24hj64gp510_ports.h │ │ │ ├── pic24hj64gp510_pyports.h │ │ │ ├── pkg100pin.pl │ │ │ ├── pkg100pinF_GA.pl │ │ │ ├── pkg100pinF_GB.pl │ │ │ ├── pkg18pin.pl │ │ │ ├── pkg28pin.pl │ │ │ ├── pkg44pin.pl │ │ │ ├── pkg64pin.pl │ │ │ ├── pkg64pinF_GA.pl │ │ │ ├── pkg64pinF_GB.pl │ │ │ ├── pkg80pinF_GA.pl │ │ │ └── pkg80pinF_GB.pl │ │ ├── doxygen │ │ │ ├── dataXfer_dox.h │ │ │ └── pic24_support_dox.h │ │ ├── pic24_adc.h │ │ ├── pic24_all.h │ │ ├── pic24_clockfreq.h │ │ ├── pic24_comparator.h │ │ ├── pic24_delay.h │ │ ├── pic24_dma.h │ │ ├── pic24_ecan.h │ │ ├── pic24_flash.h │ │ ├── pic24_generic.h │ │ ├── pic24_i2c.h │ │ ├── pic24_libconfig.h │ │ ├── pic24_ports.h │ │ ├── pic24_pyports.h │ │ ├── pic24_serial.h │ │ ├── pic24_spi.h │ │ ├── pic24_timer.h │ │ ├── pic24_uart.h │ │ ├── pic24_unittest.h │ │ ├── pic24_util.h │ │ └── stdint.h │ ├── main.c │ ├── main.py │ ├── p14p.mcp │ ├── p14p.mcw │ ├── pic24_dspic33.py │ ├── plat.c │ ├── plat.h │ ├── pmfeatures.py │ ├── pyFuncsInC.c │ ├── pyFuncsInC.h │ ├── pyToC.c │ ├── pyToC.h │ ├── readme.h │ ├── robot.py │ ├── sample_lib.py │ ├── system_test │ │ ├── adc_injection.txt │ │ ├── main.c │ │ ├── main.py │ │ ├── system_test.mcp │ │ ├── system_test.mcw │ │ ├── system_test.sbs │ │ └── system_test.scl │ ├── tools │ │ └── ipm.py │ └── unit_test │ │ ├── CuTestSmall.c │ │ ├── CuTestSmall.h │ │ ├── unit_main.c │ │ ├── unit_test.mcp │ │ └── unit_test.mcw ├── stm32 │ ├── README │ ├── SConscript │ ├── main.c │ ├── main.py │ ├── plat.c │ ├── plat.h │ ├── platform_config.h │ ├── pmfeatures.py │ ├── stm32f10x.ld │ ├── stm32f10x_conf.h │ ├── stm32f10x_it.c │ ├── stm32f10x_it.h │ ├── syscalls.c │ └── update_periph_lib.py ├── teensy │ ├── Makefile │ ├── README │ ├── main.c │ ├── main.py │ ├── plat.c │ ├── plat.h │ ├── pmfeatures.py │ ├── usb_serial.c │ └── usb_serial.h └── windows │ ├── README │ ├── SConscript │ ├── main.c │ ├── main.py │ ├── plat.c │ ├── plat.h │ ├── pmfeatures.py │ ├── py2c.bat │ ├── pymiteVS2008.sln │ ├── pymiteVS2008.vcproj │ ├── pymiteVS2010.sln │ ├── pymiteVS2010.vcxproj │ ├── pymiteVS2010.vcxproj.filters │ └── stdint.h ├── tests ├── COPYING ├── system │ ├── Makefile │ ├── SConscript │ ├── t002.c │ ├── t002.py │ ├── t003.c │ ├── t003.py │ ├── t006.c │ ├── t006.py │ ├── t009.c │ ├── t009.py │ ├── t010.c │ ├── t010.py │ ├── t013.c │ ├── t013.py │ ├── t017.c │ ├── t017.py │ ├── t020.c │ ├── t020.py │ ├── t026.c │ ├── t026.py │ ├── t047.c │ ├── t047.py │ ├── t049.c │ ├── t049.py │ ├── t050.c │ ├── t050.py │ ├── t051.c │ ├── t051.py │ ├── t054.c │ ├── t054.py │ ├── t056.c │ ├── t056.py │ ├── t058.c │ ├── t058.py │ ├── t071.c.deprecated_by_#180 │ ├── t071.py │ ├── t075.c │ ├── t075a.py │ ├── t075b.py │ ├── t076.c │ ├── t076.py │ ├── t078.c │ ├── t078.py │ ├── t080.c │ ├── t080.py │ ├── t090.c │ ├── t090.py │ ├── t094.c │ ├── t094.py │ ├── t095.c │ ├── t095.py │ ├── t096.c │ ├── t096.py │ ├── t102.c │ ├── t102.py │ ├── t103.c │ ├── t103.py │ ├── t104.c │ ├── t104.py │ ├── t108.c │ ├── t108a.py │ ├── t108b.py │ ├── t110.c │ ├── t110.py │ ├── t113.c │ ├── t113.py │ ├── t114.c │ ├── t114.py │ ├── t119.c │ ├── t119.py │ ├── t132.c │ ├── t132.py │ ├── t135.c │ ├── t135.py │ ├── t136.c │ ├── t136.py │ ├── t138.c │ ├── t138.py │ ├── t140.c │ ├── t140.py │ ├── t141.c │ ├── t141.py │ ├── t142.c │ ├── t142.py │ ├── t147.c │ ├── t147.py │ ├── t148.c │ ├── t148.py │ ├── t149.c │ ├── t149.py │ ├── t150.c │ ├── t150.py │ ├── t153.c │ ├── t153.py │ ├── t157.c │ ├── t157.py │ ├── t158.c │ ├── t158.py │ ├── t160.c │ ├── t160.py │ ├── t161.c.expectfail │ ├── t161.py │ ├── t162.c │ ├── t162.py │ ├── t164.c │ ├── t164.py │ ├── t174.c │ ├── t174.py │ ├── t187.c │ ├── t187.py │ ├── t190.c │ ├── t190.py │ ├── t202.c │ ├── t202.py │ ├── t205.c │ ├── t205.py │ ├── t207.c │ ├── t207.py │ ├── t213.c │ ├── t213.py │ ├── t230.c │ ├── t230.py │ ├── t232.c │ ├── t232.py │ ├── t233.c │ ├── t233.py │ ├── t234.c │ ├── t234.py │ ├── t235.c.requires_xrange │ ├── t235.py │ ├── t236.c │ ├── t236.py │ ├── t242.c │ ├── t242.py │ ├── t243.c │ ├── t243.py │ ├── t244.c │ ├── t244.py │ ├── t245.c │ ├── t245.py │ ├── t248.c │ ├── t248.py │ ├── t256.c │ ├── t256.py │ ├── t258.c │ ├── t258.py │ ├── t259.c │ ├── t259.py │ ├── t281.c │ ├── t281.py │ ├── t284.c │ ├── t284.py │ ├── t289.c.postponed_until_issue_#97 │ ├── t289.py │ ├── t290.c │ ├── t290.py │ ├── t291.c │ ├── t291.py │ ├── t321.c │ ├── t321.py │ ├── t329.c │ ├── t329.py │ ├── t334.c │ ├── t334.py │ ├── t347.c │ ├── t347a.py │ ├── t347b.py │ ├── t349.c │ ├── t349.py │ ├── t350.c │ ├── t350a.py │ ├── t350b.py │ ├── t352.c │ ├── t352.py │ ├── t370.c │ ├── t370.py │ ├── t374.c │ ├── t374.py │ ├── t376.c │ ├── t376.py │ ├── t377.c │ ├── t377.py │ ├── t378.c │ ├── t378d.py │ ├── t378e.py │ ├── t378f.py │ ├── t380.c │ └── t380.py └── unit │ ├── CuTest.c │ ├── CuTest.h │ ├── Makefile │ ├── runTests.c │ ├── ut_codeobj.c │ ├── ut_dict.c │ ├── ut_func.c │ ├── ut_heap.c │ ├── ut_int.c │ ├── ut_interp.c │ ├── ut_list.c │ ├── ut_seglist.c │ ├── ut_string.c │ └── ut_tuple.c ├── tools ├── COPYING ├── bcode.py ├── dismantle.py ├── ipm.py ├── pmDist.py ├── pmGenPmFeatures.py ├── pmHeapDump.py ├── pmImgCreator.py ├── pmOdDecoder.py ├── pmReplaceCopyright.py └── pycscope.py └── vm ├── .indent.pro ├── COPYING ├── Makefile ├── SConscript ├── bytearray.c ├── bytearray.h ├── class.c ├── class.h ├── codeobj.c ├── codeobj.h ├── dict.c ├── dict.h ├── fileid.txt ├── float.c ├── float.h ├── frame.c ├── frame.h ├── func.c ├── func.h ├── global.c ├── global.h ├── heap.c ├── heap.h ├── img.c ├── img.h ├── int.c ├── int.h ├── interp.c ├── interp.h ├── list.c ├── list.h ├── mem.c ├── mem.h ├── module.c ├── module.h ├── obj.c ├── obj.h ├── plat_interface.h ├── pm.c ├── pm.h ├── pmEmptyPlatformDefs.h ├── pmFeatureDependencies.h ├── seglist.c ├── seglist.h ├── seq.c ├── seq.h ├── sli.c ├── sli.h ├── strobj.c ├── strobj.h ├── thread.c ├── thread.h ├── tuple.c └── tuple.h /docs/img/BuildOverview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/docs/img/BuildOverview.png -------------------------------------------------------------------------------- /docs/src/BuildOverview.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/docs/src/BuildOverview.odg -------------------------------------------------------------------------------- /docs/src/Makefile: -------------------------------------------------------------------------------- 1 | SHELL = /bin/sh 2 | RST2HTML := rst2html.py 3 | HTML_DEST := ../html/ 4 | DOC_SOURCES := $(wildcard *.txt) 5 | DOC_HTML := $(addprefix $(HTML_DEST),$(DOC_SOURCES:.txt=.html)) 6 | 7 | 8 | .PHONY: all html clean 9 | 10 | # Generates html from restructured text source 11 | $(HTML_DEST)%.html : %.txt 12 | $(RST2HTML) $< $@ 13 | 14 | # Default action is to generate html docs 15 | all : html 16 | 17 | # Generates html documentation 18 | html : $(DOC_HTML) 19 | 20 | # Removes files made by default make 21 | clean : 22 | $(RM) $(DOC_HTML) 23 | -------------------------------------------------------------------------------- /src/platform/_unmaintained/mmb103/libmmb103.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/_unmaintained/mmb103/libmmb103.a -------------------------------------------------------------------------------- /src/platform/_unmaintained/mmb103/plat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/_unmaintained/mmb103/plat.c -------------------------------------------------------------------------------- /src/platform/arduino_mega/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** Sample PyMite application */ 16 | 17 | 18 | #include "pm.h" 19 | 20 | #define HEAP_SIZE 0x1D00 21 | 22 | 23 | extern unsigned char usrlib_img[]; 24 | 25 | 26 | int main(void) 27 | { 28 | uint8_t heap[HEAP_SIZE]; 29 | PmReturn_t retval; 30 | 31 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 32 | PM_RETURN_IF_ERROR(retval); 33 | 34 | retval = pm_run((uint8_t *)"main"); 35 | return (int)retval; 36 | } 37 | -------------------------------------------------------------------------------- /src/platform/arduino_mega/main.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | import ipm 14 | 15 | ipm.ipm() 16 | -------------------------------------------------------------------------------- /src/platform/arduino_mega/plat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/arduino_mega/plat.c -------------------------------------------------------------------------------- /src/platform/arduino_mega/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #endif /* _PLAT_H_ */ 19 | -------------------------------------------------------------------------------- /src/platform/arduino_mega/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": False, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": True, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": True, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/at91sam7s-ek/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/at91sam7s-ek/Makefile -------------------------------------------------------------------------------- /src/platform/at91sam7s-ek/README: -------------------------------------------------------------------------------- 1 | ============================ 2 | The AT91SAM7S Sample Project 3 | ============================ 4 | 5 | :Author: Dean Hall 6 | :Id: $Id$ 7 | 8 | Purpose 9 | ------- 10 | 11 | This is a sample project that demonstrates running interactive PyMite (ipm) 12 | on the Atmel `AT91SAM7S-EK`_ which is an evaluation board for the 13 | `SAM7S family`_ of microcontrollers. Any SAM7 with at least 14 | 64 KiB of program memory and 8 KiB of RAM can run PyMite. 15 | 16 | .. _`AT91SAM7S-EK`: http://atmel.com/dyn/products/tools_card.asp?tool_id=3784 17 | .. _`SAM7S family`: http://atmel.com/products/at91/default.asp 18 | 19 | 20 | Building the Project 21 | -------------------- 22 | 23 | Start with a clean PyMite tree. Build the PyMite VM archive as well as the 24 | sample application:: 25 | 26 | $ cd src/platform/avr 27 | $ make 28 | 29 | 30 | Flashing the Binary 31 | ------------------- 32 | 33 | Use your ISP programming method of choice to program 34 | ``src/platform/at91sam7s-ek/main.hex`` onto your target AVR device. 35 | 36 | .. :mode=rest: 37 | -------------------------------------------------------------------------------- /src/platform/at91sam7s-ek/lib_AT91SAM7S64.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/at91sam7s-ek/lib_AT91SAM7S64.h -------------------------------------------------------------------------------- /src/platform/at91sam7s-ek/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #define PM_PLAT_HEAP_ATTR __attribute__((aligned (4))) 19 | 20 | #endif /* _PLAT_H_ */ 21 | -------------------------------------------------------------------------------- /src/platform/at91sam7s-ek/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": False, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": False, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": False, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/avr/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** Sample PyMite application */ 16 | 17 | 18 | #include "pm.h" 19 | 20 | #define HEAP_SIZE 0x0D00 21 | 22 | 23 | extern unsigned char usrlib_img[]; 24 | 25 | 26 | int main(void) 27 | { 28 | uint8_t heap[HEAP_SIZE]; 29 | PmReturn_t retval; 30 | 31 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 32 | PM_RETURN_IF_ERROR(retval); 33 | 34 | retval = pm_run((uint8_t *)"main"); 35 | return (int)retval; 36 | } 37 | -------------------------------------------------------------------------------- /src/platform/avr/main.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # This is a sample application that calls functions in the AVR module. 15 | # 16 | print "Hello world." 17 | 18 | import avr 19 | 20 | 21 | print "Counting from 0 to 249 on portA's pins" 22 | 23 | avr.ddrA(0xFF) 24 | i = 0 25 | while i < 250: 26 | avr.portA(i) 27 | avr.delay(250) 28 | i += 1 29 | print "Done." 30 | -------------------------------------------------------------------------------- /src/platform/avr/plat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/avr/plat.c -------------------------------------------------------------------------------- /src/platform/avr/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #endif /* _PLAT_H_ */ 19 | -------------------------------------------------------------------------------- /src/platform/avr/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": False, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": False, 22 | "HAVE_ASSERT": False, 23 | "HAVE_GENERATORS": False, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": False, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": False, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/desktop/README: -------------------------------------------------------------------------------- 1 | ==================== 2 | The Desktop Platform 3 | ==================== 4 | 5 | :Author: Dean Hall 6 | :Id: $Id$ 7 | 8 | Purpose 9 | ------- 10 | 11 | This is a sample project that demonstrates running Python-on-a-Chip on the 12 | desktop. Any POSIX-compliant OS should work (Mac OS X, Linux, Cygwin). 13 | 14 | 15 | Building the Project 16 | -------------------- 17 | 18 | Start with a clean source tree. 19 | 20 | If you are running on a 64-bit processor, you will need to increase the 21 | heap size by editing ``src/platform/desktop/plat.h`` near line 18 to set 22 | ``PM_HEAP_SIZE`` to a value ``0x4000`` or larger that is a multiple of four:: 23 | 24 | #define PM_HEAP_SIZE 0x4000 25 | 26 | The desktop is the default platform of the makefile build system, 27 | so typing ``make`` in the root directory will build for the desktop:: 28 | 29 | $ make 30 | 31 | The default application is to run the interactive prompt, ipm. 32 | To run the host-side of ipm and launch the target-side type:: 33 | 34 | $ make ipm 35 | 36 | Read ``docs/src/InteractivePyMite.txt`` to learn how to run ipm. 37 | 38 | 39 | .. :mode=rest: 40 | -------------------------------------------------------------------------------- /src/platform/desktop/SConscript: -------------------------------------------------------------------------------- 1 | Import("vars") 2 | 3 | vars.Add("IPM", "Add the interactive library to the standard lib", True) 4 | 5 | CFLAGS = "-Os -Wall -gstabs -Wstrict-prototypes -Werror" 6 | if "DEBUG" in vars.args.keys(): 7 | CFLAGS = "-g -ggdb -D__DEBUG__=1 " + CFLAGS 8 | SOURCES = ["main.c", "plat.c"] 9 | PY_SOURCES = ["main.py"] 10 | PM_LIB_ROOT = ["pmvm_%s" % vars.args["PLATFORM"]] 11 | 12 | env = Environment(variables = vars, 13 | CPPPATH = ["#src/vm", "#src/platform/desktop"], 14 | CCFLAGS = CFLAGS) 15 | 16 | vmlib = SConscript(["../../vm/SConscript"], ["env", "vars"]) 17 | img_sources = Command(["main_img.c", "main_nat.c"], [PY_SOURCES], 18 | "src/tools/pmImgCreator.py -c -u -o src/platform/desktop/main_img.c" \ 19 | " --native-file=src/platform/desktop/main_nat.c $SOURCES") 20 | main = env.Program("main.out", SOURCES + img_sources, 21 | LIBS = PM_LIB_ROOT, LIBPATH = ["../../vm"]) 22 | -------------------------------------------------------------------------------- /src/platform/desktop/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | 16 | #include "pm.h" 17 | 18 | #define HEAP_SIZE 0x2000 19 | 20 | extern unsigned char usrlib_img[]; 21 | 22 | 23 | int main(void) 24 | { 25 | uint8_t heap[HEAP_SIZE]; 26 | PmReturn_t retval; 27 | 28 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 29 | PM_RETURN_IF_ERROR(retval); 30 | 31 | retval = pm_run((uint8_t *)"main"); 32 | return (int)retval; 33 | } 34 | -------------------------------------------------------------------------------- /src/platform/desktop/main.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # Runs the interactive interpreter 15 | # 16 | 17 | 18 | import ipm 19 | ipm.ipm() 20 | -------------------------------------------------------------------------------- /src/platform/desktop/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #define PM_FLOAT_LITTLE_ENDIAN 19 | #define PM_PLAT_HEAP_ATTR __attribute__((aligned (4))) 20 | 21 | #endif /* _PLAT_H_ */ 22 | -------------------------------------------------------------------------------- /src/platform/desktop/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": True, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": True, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": True, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/econotag/main.c: -------------------------------------------------------------------------------- 1 | /** \file 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #include "pm.h" 16 | 17 | #define HEAP_SIZE 0x4000 18 | 19 | extern unsigned char usrlib_img[]; 20 | 21 | int 22 | main(void) 23 | { 24 | uint8_t heap[HEAP_SIZE]; 25 | PmReturn_t retval; 26 | 27 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 28 | PM_RETURN_IF_ERROR(retval); 29 | 30 | /* Run the sample program */ 31 | retval = pm_run((uint8_t *)"main"); 32 | 33 | return (int)retval; 34 | } -------------------------------------------------------------------------------- /src/platform/econotag/main.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2002 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | import ipm 9 | ipm.ipm() 10 | -------------------------------------------------------------------------------- /src/platform/econotag/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #endif /* _PLAT_H_ */ 19 | -------------------------------------------------------------------------------- /src/platform/econotag/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": False, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": True, 27 | "HAVE_BYTEARRAY": True, 28 | "HAVE_DEBUG_INFO": False, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/mbed/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/mbed/Makefile -------------------------------------------------------------------------------- /src/platform/mbed/TextLCD.lib: -------------------------------------------------------------------------------- 1 | http://mbed.co.uk/projects/cookbook/svn/TextLCD/trunk@495 -------------------------------------------------------------------------------- /src/platform/mbed/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | 16 | #include "pm.h" 17 | 18 | 19 | #ifdef __cplusplus 20 | extern 21 | #endif 22 | 23 | #define HEAP_SIZE 0x7000 24 | 25 | unsigned char const usrlib_img[]; 26 | 27 | 28 | int 29 | main(void) 30 | { 31 | uint8_t heap[HEAP_SIZE]; 32 | PmReturn_t retval; 33 | 34 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 35 | PM_RETURN_IF_ERROR(retval); 36 | 37 | /* Run the sample program */ 38 | retval = pm_run((uint8_t *)"main"); 39 | 40 | return (int)retval; 41 | } 42 | -------------------------------------------------------------------------------- /src/platform/mbed/main.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | import ipm 14 | ipm.ipm(globals()) 15 | -------------------------------------------------------------------------------- /src/platform/mbed/mbed.lib: -------------------------------------------------------------------------------- 1 | http://mbed.co.uk/projects/libraries/svn/mbed/trunk@13 -------------------------------------------------------------------------------- /src/platform/mbed/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #define PM_FLOAT_LITTLE_ENDIAN 19 | #define PM_PLAT_HEAP_ATTR __attribute__((aligned (4))) 20 | 21 | #endif /* _PLAT_H_ */ 22 | -------------------------------------------------------------------------------- /src/platform/mbed/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": True, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": True, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": True, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/mosync/Makefile: -------------------------------------------------------------------------------- 1 | # PyMite Configuration 2 | PLATFORM := $(notdir $(CURDIR)) 3 | PM_LIB_ROOT = pmvm_$(PLATFORM) 4 | PM_LIB_FN = lib$(PM_LIB_ROOT).a 5 | PM_LIB_PATH = ../../vm/$(PM_LIB_FN) 6 | PM_USR_SOURCES = main.py ma.py 7 | PMIMGCREATOR := ../../tools/pmImgCreator.py 8 | PMGENPMFEATURES := ../../tools/pmGenPmFeatures.py 9 | #IPM = true 10 | #DEBUG = true 11 | 12 | TARGET = main 13 | 14 | .PHONY: all clean 15 | 16 | all : pmfeatures.h $(TARGET)_nat.c $(TARGET)_img.c ../../vm/pmstdlib_img.c ../../vm/pmstdlib_nat.c 17 | 18 | pmfeatures.h : pmfeatures.py $(PMGENPMFEATURES) 19 | $(PMGENPMFEATURES) pmfeatures.py > $@ 20 | 21 | # Build the standard libraries 22 | ../../vm/pmstdlib_img.c ../../vm/pmstdlib_nat.c : 23 | $(MAKE) PLATFORM=mosync -C ../../vm bytecode 24 | 25 | # Generate native code and module images from the python source 26 | $(TARGET)_nat.c $(TARGET)_img.c: $(PM_USR_SOURCES) pmfeatures.py 27 | $(PMIMGCREATOR) -f pmfeatures.py -c -u -o $(TARGET)_img.c --native-file=$(TARGET)_nat.c $(PM_USR_SOURCES) 28 | 29 | clean : 30 | $(RM) $(TARGET)_img.* $(TARGET)_nat.* pmfeatures.h ../../vm/pmstdlib_img.c ../../vm/pmstdlib_nat.c 31 | -------------------------------------------------------------------------------- /src/platform/mosync/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #include "pm.h" 16 | #define HEAP_SIZE 0x10000 // 256k 17 | extern unsigned char usrlib_img[]; 18 | int MAMain() 19 | { 20 | uint8_t heap[HEAP_SIZE]; 21 | PmReturn_t retval; 22 | 23 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 24 | PM_RETURN_IF_ERROR(retval); 25 | 26 | retval = pm_run((uint8_t *)"main"); 27 | return (int)retval; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/platform/mosync/p14p.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/mosync/p14p.png -------------------------------------------------------------------------------- /src/platform/mosync/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #define PM_FLOAT_LITTLE_ENDIAN 19 | #define PM_PLAT_HEAP_ATTR __attribute__((aligned (4))) 20 | 21 | #endif /* _PLAT_H_ */ 22 | -------------------------------------------------------------------------------- /src/platform/mosync/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": True, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": True, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": True, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/mosync/resources.lst: -------------------------------------------------------------------------------- 1 | .res RES_LOGO 2 | .image "p14p.png" 3 | -------------------------------------------------------------------------------- /src/platform/pic24/README: -------------------------------------------------------------------------------- 1 | See the documentation in readme.h for more information. 2 | This information can be presented in HTML by using the 3 | "make html" target. 4 | -------------------------------------------------------------------------------- /src/platform/pic24/common/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | Files in this directory have PIC24_ as the prefix so as not to 3 | clash with system files. 4 | -------------------------------------------------------------------------------- /src/platform/pic24/crlf.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | "Replace CRLF with LF in argument files. Print names of changed files." 3 | 4 | import sys, os 5 | 6 | def main(): 7 | for filename in sys.argv[1:]: 8 | if os.path.isdir(filename): 9 | print filename, "Directory!" 10 | continue 11 | data = open(filename, "rb").read() 12 | if '\0' in data: 13 | print filename, "Binary!" 14 | continue 15 | newdata = data.replace("\r\n", "\n") 16 | if newdata != data: 17 | print filename 18 | f = open(filename, "wb") 19 | f.write(newdata) 20 | f.close() 21 | 22 | if __name__ == '__main__': 23 | main() 24 | -------------------------------------------------------------------------------- /src/platform/pic24/fixcrlf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | #This batch file changes CR/LF line endings to pure LF line endings to be Unix-compliant. 3 | #It relies on crlf.py, taken from the Windows Python 2.5 distribution. 4 | python crlf.py *.c *.h *.py Makefile README common/*.c 5 | python crlf.py include/*.h include/devices/*.h include/devices/*.pl 6 | python crlf.py unit_test/*.h unit_test/*.c 7 | python crlf.py system_test/*.c system_test/*.py 8 | -------------------------------------------------------------------------------- /src/platform/pic24/heapsize.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _HEAPSIZE_H_ 16 | #define _HEAPSIZE_H_ 17 | 18 | #define HS 6892 19 | // Make room for the debugger if necessary 20 | #ifdef __DEBUG 21 | #define HEAP_SIZE (HS - 80) 22 | #else 23 | #define HEAP_SIZE HS 24 | #endif 25 | 26 | #endif /* _HEAPSIZE_H_ */ 27 | -------------------------------------------------------------------------------- /src/platform/pic24/include/dataXferImpl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/pic24/include/dataXferImpl.h -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/get_devices.pl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | while () { 5 | chop; 6 | s/\.h//g; 7 | s/\//g; 9 | @words = split; 10 | if (@words > 1) { 11 | if ($words[0] eq "#include") { 12 | print "$words[1]\n"; 13 | 14 | } 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24_deviceids.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/pic24/include/devices/pic24_deviceids.xlsx -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj128ga006_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj128ga008_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj128ga010_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj128ga106_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj128gb106_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj192ga106_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj192gb106_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj256ga106_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj256gb106_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj64ga006_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj64ga008_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj64ga010_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj64gb106_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj96ga006_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj96ga008_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24fj96ga010_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24hj128gp206_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24hj128gp306_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24hj128gp506_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24hj256gp206_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24hj64gp206_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/devices/pic24hj64gp506_pyports.h: -------------------------------------------------------------------------------- 1 | #define AN_CN_MAP \ 2 | /* AN pin , CN pin */ \ 3 | /* -----------, ------------ */ 4 | 5 | #define _PIC24_PYDIGIO_DEFINED 6 | -------------------------------------------------------------------------------- /src/platform/pic24/include/pic24_comparator.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/pic24/include/pic24_comparator.h -------------------------------------------------------------------------------- /src/platform/pic24/main.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | ## @file 14 | # @brief PIC24/dsPIC33 main code to run ipm. 15 | # 16 | 17 | import ipm 18 | print "Welcome to PIC24/dsPIC33 Python! Starting interactive mode." 19 | ipm.ipm() 20 | -------------------------------------------------------------------------------- /src/platform/pic24/p14p.mcw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/pic24/p14p.mcw -------------------------------------------------------------------------------- /src/platform/pic24/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #define PM_FLOAT_LITTLE_ENDIAN 19 | 20 | #endif /* _PLAT_H_ */ 21 | -------------------------------------------------------------------------------- /src/platform/pic24/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": True, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": True, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": True, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/pic24/system_test/adc_injection.txt: -------------------------------------------------------------------------------- 1 | 0x01A4 2 | -------------------------------------------------------------------------------- /src/platform/pic24/system_test/system_test.mcw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/pic24/system_test/system_test.mcw -------------------------------------------------------------------------------- /src/platform/pic24/system_test/system_test.sbs: -------------------------------------------------------------------------------- 1 | ## SCL Builder Setup File: Do not edit!! 2 | 3 | ## VERSION: 3.60.00.00 4 | ## FORMAT: v2.00.01 5 | ## DEVICE: PIC24HJ128GP504 6 | 7 | ## PINREGACTIONS 8 | cyc 9 | No Repeat 10 | -- 11 | & 12 | ## ADVPINREGACTIONS 13 | -- 14 | & 15 | -- 16 | COND1 17 | Any 18 | 19 | 20 | 21 | 22 | 23 | 24 | -- 25 | & 26 | ## CLOCK 27 | & 28 | ## STIMULUSFILE 29 | 30 | ADC1BUF0 31 | Demand 32 | 00000 33 | 2 34 | adc_injection.txt 35 | Hex 36 | Yes 37 | (optional) 38 | -- 39 | & 40 | ## RESPONSEFILE 41 | & 42 | ## ASYNCH 43 | & 44 | ## ADVANCEDSCL 45 | c:\users\bjones\documents\svns\p14p_pic24port\src\platform\pic24\system_test\system_test.scl 46 | 0 47 | & 48 | -------------------------------------------------------------------------------- /src/platform/pic24/system_test/system_test.scl: -------------------------------------------------------------------------------- 1 | // 2 | // C:\Users\bjones\Documents\svns\p14p_pic24port\src\platform\pic24\system_test\system_test.scl 3 | // Generated by Stimulus ver. 3.60.00.00 4 | // 7/5/2010 10:40:27 5 | // 6 | 7 | 8 | configuration for "pic24hj128gp504" is 9 | end configuration; 10 | 11 | 12 | testbench for "pic24hj128gp504" is 13 | begin 14 | process is 15 | begin 16 | wait; 17 | end process; 18 | 19 | // Register Injection 20 | process is 21 | begin 22 | accessin("adc_injection.txt", hex_mode, ADC1BUF0, true); 23 | wait; 24 | end process; 25 | 26 | end testbench; 27 | 28 | -------------------------------------------------------------------------------- /src/platform/pic24/unit_test/unit_test.mcw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/pic24/unit_test/unit_test.mcw -------------------------------------------------------------------------------- /src/platform/stm32/main.c: -------------------------------------------------------------------------------- 1 | /** \file 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #include "pm.h" 16 | 17 | #define HEAP_SIZE 0x7000 18 | 19 | extern unsigned char usrlib_img[]; 20 | 21 | int 22 | main(void) 23 | { 24 | uint8_t heap[HEAP_SIZE]; 25 | PmReturn_t retval; 26 | 27 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 28 | PM_RETURN_IF_ERROR(retval); 29 | 30 | /* Run the sample program */ 31 | retval = pm_run((uint8_t *)"main"); 32 | 33 | return (int)retval; 34 | } -------------------------------------------------------------------------------- /src/platform/stm32/main.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2002 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | import ipm 9 | ipm.ipm() 10 | 11 | # :mode=c: 12 | -------------------------------------------------------------------------------- /src/platform/stm32/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #define PM_FLOAT_LITTLE_ENDIAN 19 | 20 | #endif /* _PLAT_H_ */ 21 | -------------------------------------------------------------------------------- /src/platform/stm32/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": True, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": False, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": False, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/teensy/plat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsnyder/python-on-a-chip/a22fbae773b285ccf4993905a46dd396cb762f69/src/platform/teensy/plat.c -------------------------------------------------------------------------------- /src/platform/teensy/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #endif /* _PLAT_H_ */ 19 | -------------------------------------------------------------------------------- /src/platform/teensy/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": False, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": False, 23 | "HAVE_GENERATORS": False, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": False, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": False, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/windows/main.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2002 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | # 9 | # Runs the interactive interpreter 10 | # 11 | 12 | print "Hello" 13 | 14 | import ipm 15 | ipm.ipm(globals()) 16 | 17 | print "Good-bye" -------------------------------------------------------------------------------- /src/platform/windows/plat.h: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | #ifndef _PLAT_H_ 16 | #define _PLAT_H_ 17 | 18 | #include 19 | 20 | // MSVC does not define a stock snprintf, so we define one here 21 | #if defined(_MSC_VER) 22 | //#define snprintf _snprintf 23 | #define snprintf(buf, count, format, ...) _snprintf_s(buf, count, _TRUNCATE, format, __VA_ARGS__) 24 | #endif 25 | 26 | #define PM_FLOAT_LITTLE_ENDIAN 27 | 28 | #endif /* _PLAT_H_ */ 29 | -------------------------------------------------------------------------------- /src/platform/windows/pmfeatures.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | PM_FEATURES = { 14 | "HAVE_PRINT": True, 15 | "HAVE_GC": True, 16 | "HAVE_FLOAT": True, 17 | "HAVE_DEL": True, 18 | "HAVE_IMPORTS": True, 19 | "HAVE_DEFAULTARGS": True, 20 | "HAVE_REPLICATION": True, 21 | "HAVE_CLASSES": True, 22 | "HAVE_ASSERT": True, 23 | "HAVE_GENERATORS": True, 24 | "HAVE_BACKTICK": True, 25 | "HAVE_STRING_FORMAT": True, 26 | "HAVE_CLOSURES": True, 27 | "HAVE_BYTEARRAY": False, 28 | "HAVE_DEBUG_INFO": True, 29 | } 30 | -------------------------------------------------------------------------------- /src/platform/windows/py2c.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Simple batch file to generate the needed .h,.c files 3 | @rem for building with an IDE like VS or Keil 4 | @rem 5 | @rem Assumes python.exe is on the path 6 | 7 | @rem build the pmfeatures.h 8 | python ../../tools/pmGenPmFeatures.py pmfeatures.py > pmfeatures.h 9 | 10 | @rem build the 'system' libraries 11 | python ../../tools/pmImgCreator.py -f pmfeatures.py -c -s -o ../../vm/pmstdlib_img.c --native-file=../../vm/pmstdlib_nat.c ../../lib/ipm.py ../../lib/list.py ../../lib/dict.py ../../lib/__bi.py ../../lib/sys.py ../../lib/string.py 12 | 13 | @rem build the 'local' libraries 14 | python ../../tools/pmImgCreator.py -f pmfeatures.py -c -u -o main_img.c --native-file=main_nat.c main.py 15 | -------------------------------------------------------------------------------- /src/platform/windows/pymiteVS2008.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual C++ Express 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pymite", "pymiteVS2008.vcproj", "{95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Debug|Win32.Build.0 = Debug|Win32 14 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Release|Win32.ActiveCfg = Release|Win32 15 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /src/platform/windows/pymiteVS2010.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual C++ Express 2010 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pymite", "pymiteVS2010.vcxproj", "{95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Win32 = Debug|Win32 8 | Release|Win32 = Release|Win32 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Debug|Win32.ActiveCfg = Debug|Win32 12 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Debug|Win32.Build.0 = Debug|Win32 13 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Release|Win32.ActiveCfg = Release|Win32 14 | {95D2BB14-A2AD-4CB9-8AEF-EE5F5F9A3C60}.Release|Win32.Build.0 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /src/platform/windows/stdint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Small stdint.h replacement to be used with the MS Visual C++ environment 3 | */ 4 | 5 | #ifndef __stdint_h__ 6 | #define __stdint_h__ 7 | 8 | #if defined(_MSC_VER) 9 | // Visual Studio does not include stdint.h, so we do it inline here 10 | typedef char int8_t; 11 | typedef short int16_t; 12 | typedef int int32_t; 13 | typedef unsigned char uint8_t; 14 | typedef unsigned short uint16_t; 15 | typedef unsigned int uint32_t; 16 | 17 | // change the default VS _DEBUG into PyMite __DEBUG__ 18 | #if defined(_DEBUG) 19 | #define __DEBUG__ 1 20 | #endif 21 | #else 22 | //#include 23 | #endif 24 | 25 | 26 | #endif /* __stdint_h__ */ -------------------------------------------------------------------------------- /src/tests/system/t002.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * Feature Test for Issue #2 17 | * Separate stdlib from user app 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t002"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t003.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 003 Unrelated to issue #3. 17 | * Load a module image from RAM using the global image info list. 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t003"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t003.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 003 Unrelated to issue #3. 15 | # A module that has two simple functions, and calls them via main(). 16 | # 17 | 18 | 19 | def a(a1, a2): 20 | """ 21 | Return the sum of a1 and a2. 22 | """ 23 | return a1 + a2 24 | 25 | 26 | def b(b1, b2): 27 | """ 28 | Return the difference between b1 and b2. 29 | """ 30 | return b1 - b2 31 | 32 | 33 | def main(): 34 | a(2, 5) 35 | b(2, 6) 36 | return 37 | 38 | 39 | main() 40 | -------------------------------------------------------------------------------- /src/tests/system/t006.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # Regression Test for Issue #6 15 | # Ensure an image list is null terminated. 16 | # Only need a dummy module. 17 | # 18 | 19 | 20 | pass 21 | -------------------------------------------------------------------------------- /src/tests/system/t009.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * Regression Test for Issue #9 17 | * Fix BINARY_SUBSCR for case stringobj[intobj] 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t009"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t009.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # Regression Test for Issue #9 15 | # Fix BINARY_SUBSCR for case stringobj[intobj] 16 | # 17 | 18 | import sys 19 | 20 | s = "test" 21 | if s[0] != 't': 22 | sys.exit(1) 23 | -------------------------------------------------------------------------------- /src/tests/system/t010.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * Regression Test for Issue #10 17 | * Create sequence_getSubscript() 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t010"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t013.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 013 17 | * Implement the equivalent of '__name__ == "__main__"' in module attrs 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t013"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t013.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 013 15 | # Implement the equivalent of '__name__ == "__main__"' in module attrs 16 | # 17 | 18 | if ismain(): 19 | print "In main." 20 | else: 21 | print "Not in main." 22 | -------------------------------------------------------------------------------- /src/tests/system/t017.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 017 17 | * Tests implementation of seq_compare() 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t017"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t017.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 017 15 | # Tests implementation of seq_compare() 16 | # 17 | 18 | 19 | l1 = [2,5,6] 20 | l2 = [2,5,6] 21 | assert l1 == l2 22 | 23 | l3 = [2,5,5] 24 | assert l2 != l3 25 | 26 | t1 = (2,5,6) 27 | t2 = (2,5,6) 28 | assert t1 == t2 29 | 30 | t3 = (2,5,5) 31 | assert t2 != t3 32 | -------------------------------------------------------------------------------- /src/tests/system/t020.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * Feature Test for Issue #20 17 | * Implement assert statement 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t020"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t020.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # Feature Test for Issue #20 15 | # 16 | # Implement assert statement 17 | # 18 | 19 | 20 | assert None != 0 21 | 22 | # Uncomment the following if try/except is implemented 23 | #try: 24 | # assert 6 == 42 25 | #exception AssertionError: 26 | # pass 27 | -------------------------------------------------------------------------------- /src/tests/system/t026.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 026 17 | * Tests new builtin functions 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t026"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t049.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 049 17 | * Tests implementation of obj_isFalse() for Tuple, List and Dict. 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t049"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t049.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 049 15 | # Tests implementation of obj_isFalse() for Tuple, List and Dict. 16 | # 17 | 18 | 19 | t1 = () 20 | if t1: 21 | assert 0 22 | 23 | t2 = (2,) 24 | if not t2: 25 | assert 0 26 | 27 | l1 = [] 28 | if l1: 29 | assert 0 30 | 31 | l2 = [2,] 32 | if not l2: 33 | assert 0 34 | 35 | d1 = {} 36 | if d1: 37 | assert 0 38 | 39 | d2 = {2:2} 40 | if not d2: 41 | assert 0 42 | -------------------------------------------------------------------------------- /src/tests/system/t050.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * Feature Test for Issue #50 17 | * Integrate __LINE__ into PM_RAISE 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t050"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t050.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # Feature Test for Issue #50 15 | # 16 | # Integrate __LINE__ into PM_RAISE 17 | # 18 | # To check that PM_RAISE works, I made a simple code snippet below that 19 | # will exercise specific functions in int.c 20 | # 21 | 22 | n = 1 23 | 24 | n0 = +n 25 | assert n0 == 1 26 | 27 | n1 = ~n 28 | assert n1 == -2 29 | 30 | n2 = -n 31 | assert n2 == -1 32 | -------------------------------------------------------------------------------- /src/tests/system/t051.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 051 17 | * Tests implementation of FOR_ITER bytecode 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t051"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t051.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 051 15 | # Tests implementation of FOR_ITER bytecode 16 | # 17 | 18 | 19 | s = (2,5,6) 20 | n = 0 21 | for i in s: 22 | assert s[n] == i 23 | n += 1 24 | 25 | 26 | s = [2,5,6] 27 | n = 0 28 | for i in s: 29 | assert s[n] == i 30 | n += 1 31 | 32 | 33 | s = "256" 34 | n = 0 35 | for i in s: 36 | assert s[n] == i 37 | n += 1 38 | -------------------------------------------------------------------------------- /src/tests/system/t054.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 054 17 | * Tests lists and dicts with lengths > 8 to test underlying seglist. 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t054"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t054.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 054 15 | # Tests lists and dicts with lengths > 8 to test underlying seglist. 16 | # 17 | 18 | 19 | l = range(9) 20 | assert l[0] == 0 21 | assert l[8] == 8 22 | assert l[-1] == 8 23 | 24 | assert len(l) == 9 25 | 26 | # TODO Activate once a solution for #47 is found 27 | #l.remove(0) 28 | #assert not 0 in l 29 | #assert 1 in l 30 | #assert len(l) == 8 31 | 32 | 33 | d = {} 34 | i = 9 35 | while i >= 0: 36 | d[i] = i 37 | i -= 1 38 | assert d[0] == 0 39 | assert d[9] == 9 40 | -------------------------------------------------------------------------------- /src/tests/system/t056.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 056 17 | * Tests implementation of *_POWER bytecodes 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t056"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t056.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 056 15 | # Tests implementation of *_POWER bytecodes 16 | # 17 | 18 | 19 | x = 2 ** 8 20 | assert x == 256 21 | 22 | x = 4 23 | x = x ** x 24 | assert x == 256 25 | -------------------------------------------------------------------------------- /src/tests/system/t058.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 058 17 | * Tests implementation of keyword "in" for Tuple, List and String 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t058"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t071.c.deprecated_by_#180: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 071 17 | * Tests implementation of builtin function eval() 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | extern unsigned char usrlib_img[]; 24 | 25 | 26 | int main(void) 27 | { 28 | PmReturn_t retval; 29 | 30 | retval = pm_init(MEMSPACE_PROG, usrlib_img); 31 | PM_RETURN_IF_ERROR(retval); 32 | 33 | retval = pm_run((uint8_t *)"t071"); 34 | return (int)retval; 35 | } 36 | -------------------------------------------------------------------------------- /src/tests/system/t075a.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 061 part A 15 | # Testing two threads starting at the same time, each calculating a number 16 | # and printing it 17 | # 18 | 19 | 20 | print "Thread A" 21 | x = -42 22 | y = 12 23 | for i in range(10): 24 | x += i 25 | y -= i 26 | print x*y 27 | -------------------------------------------------------------------------------- /src/tests/system/t075b.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 061 part B 15 | # Testing two threads starting at the same time, each calculating a number 16 | # and printing it 17 | # 18 | 19 | 20 | print "Thread B" 21 | a = 666 22 | b = -2 23 | for i in range(10): 24 | a += i 25 | b -= i 26 | print a*b 27 | -------------------------------------------------------------------------------- /src/tests/system/t076.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 076 15 | # Tests if print operation properly outputs string along with a newline. 16 | # Also tests proper escaping when outputting strings in dicts and lists. 17 | # printing integers, dicts and lists. 18 | # 19 | 20 | a = "123\x08456" 21 | b = 987 22 | c = [a,b] 23 | d = {a:b} 24 | e = (c,d) 25 | print a 26 | print b 27 | print c 28 | print d 29 | print e 30 | -------------------------------------------------------------------------------- /src/tests/system/t078.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 078 17 | * Tests that module import works properly 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t078"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t078.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 078 15 | # 16 | # Tests that module import works properly 17 | # 18 | 19 | import sys 20 | assert sys != None 21 | assert sys.exit != None 22 | -------------------------------------------------------------------------------- /src/tests/system/t080.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 080 17 | * Regression test for issue #80: Fix bytecode DUP_TOPX. 18 | */ 19 | 20 | #include "pm.h" 21 | #include "stdio.h" 22 | 23 | 24 | #define HEAP_SIZE 0x2000 25 | 26 | extern unsigned char usrlib_img[]; 27 | 28 | 29 | int main(void) 30 | { 31 | uint8_t heap[HEAP_SIZE]; 32 | PmReturn_t retval; 33 | 34 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 35 | PM_RETURN_IF_ERROR(retval); 36 | 37 | retval = pm_run((uint8_t *)"t080"); 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t080.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 080 15 | # Regression test for issue #80: Fix bytecode DUP_TOPX. 16 | # 17 | 18 | d = {} 19 | d[0] = 42 20 | d[0] += 99 21 | assert d[0] == 141 22 | 23 | r = range(3) 24 | r[1] += 99 25 | assert r[1] == 100 26 | -------------------------------------------------------------------------------- /src/tests/system/t090.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * Test for Issue #90 17 | * Create new lib function to return system time 18 | */ 19 | 20 | 21 | #include "pm.h" 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t090"); 37 | return (int)retval; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/tests/system/t094.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 094 15 | # Fix image integer loading so it re-uses static ints (-1,0,1). 16 | # 17 | 18 | kn1 = 1 - 2 19 | k0 = kn1 + 1 20 | k1 = k0 + 1 21 | 22 | id1 = id(-1) 23 | id2 = id(kn1) 24 | assert id1 == id2 25 | 26 | id1 = id(0) 27 | id2 = id(k0) 28 | assert id1 == id2 29 | 30 | id1 = id(1) 31 | id2 = id(k1) 32 | assert id1 == id2 33 | -------------------------------------------------------------------------------- /src/tests/system/t095.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 095 17 | * Fix sys.heap() so it doesn't overwrite the static const 0 integer obj 18 | */ 19 | 20 | #include "pm.h" 21 | #include "stdio.h" 22 | 23 | 24 | #define HEAP_SIZE 0x2000 25 | 26 | extern unsigned char usrlib_img[]; 27 | 28 | 29 | int main(void) 30 | { 31 | uint8_t heap[HEAP_SIZE]; 32 | PmReturn_t retval; 33 | 34 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 35 | PM_RETURN_IF_ERROR(retval); 36 | 37 | retval = pm_run((uint8_t *)"t095"); 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t095.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 095 15 | # Fix sys.heap() so it doesn't overwrite the static const 0 integer obj 16 | # 17 | 18 | import sys 19 | 20 | h = sys.heap() 21 | 22 | assert h[0] != (1-1) 23 | -------------------------------------------------------------------------------- /src/tests/system/t096.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 096 17 | * Create library function to spawn a new thread 18 | */ 19 | 20 | #include "pm.h" 21 | #include "stdio.h" 22 | 23 | 24 | #define HEAP_SIZE 0x2000 25 | 26 | extern unsigned char usrlib_img[]; 27 | 28 | 29 | int main(void) 30 | { 31 | uint8_t heap[HEAP_SIZE]; 32 | PmReturn_t retval; 33 | 34 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 35 | PM_RETURN_IF_ERROR(retval); 36 | 37 | retval = pm_run((uint8_t *)"t096"); 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t102.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 102 17 | * Implement the remaining IMPORT_ bytecodes 18 | */ 19 | 20 | #include "pm.h" 21 | #include "stdio.h" 22 | 23 | 24 | #define HEAP_SIZE 0x2000 25 | 26 | extern unsigned char usrlib_img[]; 27 | 28 | 29 | int main(void) 30 | { 31 | uint8_t heap[HEAP_SIZE]; 32 | PmReturn_t retval; 33 | 34 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 35 | PM_RETURN_IF_ERROR(retval); 36 | 37 | retval = pm_run((uint8_t *)"t102"); 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t102.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 102 15 | # Implement the remaining IMPORT_ bytecodes 16 | # 17 | 18 | # Test IMPORT_FROM 19 | from sys import maxint 20 | assert maxint == 0x7fffffff 21 | 22 | # Test IMPORT_STAR 23 | from sys import * 24 | assert type(heap) == 0x08 25 | assert type(exit) == 0x08 26 | -------------------------------------------------------------------------------- /src/tests/system/t103.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 103 17 | * Implement obj_print() for other object types 18 | */ 19 | 20 | #include "pm.h" 21 | #include "stdio.h" 22 | 23 | 24 | #define HEAP_SIZE 0x2000 25 | 26 | extern unsigned char usrlib_img[]; 27 | 28 | 29 | int main(void) 30 | { 31 | uint8_t heap[HEAP_SIZE]; 32 | PmReturn_t retval; 33 | 34 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 35 | PM_RETURN_IF_ERROR(retval); 36 | 37 | retval = pm_run((uint8_t *)"t103"); 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t103.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 103 15 | # Implement obj_print() for other object types 16 | # 17 | 18 | import sys 19 | 20 | def f(a,b): 21 | return a+b 22 | 23 | # 24 | # If the following throws an exception, it's a regression 25 | # 26 | print f, sys 27 | -------------------------------------------------------------------------------- /src/tests/system/t104.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * Test for Issue #104 17 | * Design and implement garbage collection 18 | */ 19 | 20 | 21 | #include "pm.h" 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t104"); 37 | return (int)retval; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/tests/system/t104.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # Test for Issue #104: Design and implement garbage collection 15 | # 16 | # Run code that will cause a GC and then run more code to see that things 17 | # still work. 18 | # 19 | 20 | import sys 21 | 22 | print "Heap =", sys.heap() 23 | 24 | # Make this value smaller as available heap decreases. 25 | i = 140 26 | r = range(i) 27 | print "r = range(", i, ")" 28 | 29 | print "Heap =", sys.heap() 30 | 31 | while i > 0: 32 | i -= 1 33 | r[i] += 10 34 | print "r[i] += 10; for all i" 35 | print "Heap =", sys.heap() 36 | print "Done." 37 | -------------------------------------------------------------------------------- /src/tests/system/t108.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009, 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 108 17 | * Fix error in GC where object pointer is invalid 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t108a"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t108a.py: -------------------------------------------------------------------------------- 1 | # Anything that starts with a # is a comment! 2 | # Use lots of comments in your code to explain what you're doing. 3 | 4 | # Use the PIC-specific Python libraries 5 | import t108b as pic 6 | 7 | 8 | ############################################################### 9 | # Set up line sensors, distance sensor, motors 10 | ############################################################### 11 | 12 | line_sensor_right = pic.digital_io(1, 8, True) 13 | right_wheel_stopped = 938 14 | 15 | def drive_forward(): 16 | right_wheel.setCounts(right_wheel_forward) 17 | 18 | def stop_driving(): 19 | right_wheel.setCounts(right_wheel_stopped) 20 | 21 | 22 | ############################################################### 23 | # Main loop 24 | ############################################################### 25 | 26 | print "Running..." 27 | i = 0; 28 | while i < 10000: 29 | i = i + 1 30 | # Print out line following diags 31 | if line_sensor_right.get(): 32 | pass 33 | -------------------------------------------------------------------------------- /src/tests/system/t108b.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | class digital_io(object): 14 | def __init__(self, port, pin, isInput): 15 | pass 16 | def get(self,): 17 | return True 18 | -------------------------------------------------------------------------------- /src/tests/system/t110.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 110 17 | * Prevent IMPORT_NAME from reloading existing module 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t110"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t110.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 110 15 | # Prevent IMPORT_NAME from reloading existing module 16 | # 17 | # This test shows that the list module is not reloaded. 18 | # A regression of this test will result in a KeyError (zero not in list's attrs) 19 | # 20 | 21 | import list 22 | list.zero = 0 23 | 24 | import list 25 | assert list.zero == 0 26 | -------------------------------------------------------------------------------- /src/tests/system/t113.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 113 17 | * Fix the implementation of builtin map() 18 | */ 19 | 20 | #include "pm.h" 21 | #include "stdio.h" 22 | 23 | 24 | #define HEAP_SIZE 0x2000 25 | 26 | extern unsigned char usrlib_img[]; 27 | 28 | 29 | int main(void) 30 | { 31 | uint8_t heap[HEAP_SIZE]; 32 | PmReturn_t retval; 33 | 34 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 35 | PM_RETURN_IF_ERROR(retval); 36 | 37 | retval = pm_run((uint8_t *)"t113"); 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t113.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 113 15 | # 16 | # Regression test for issue #113: 17 | # Fix the implementation of builtin map() 18 | # 19 | 20 | # Test setting each value to None 21 | def noneify(a): 22 | return None 23 | 24 | r = map(noneify, "test") 25 | 26 | assert r == [None, None, None, None] 27 | 28 | 29 | # Test adding a tuple pair 30 | def addPair(a): 31 | return a[0] + a[1] 32 | 33 | r = map(addPair, ((3,4),(5,6),(7,8))) 34 | 35 | assert r == [7, 11, 15] 36 | -------------------------------------------------------------------------------- /src/tests/system/t114.py: -------------------------------------------------------------------------------- 1 | # Anything that starts with a # is a comment! 2 | # Use lots of comments in your code to explain what you're doing. 3 | 4 | # Use the PIC-specific Python libraries 5 | import t114 as pic 6 | 7 | line_sensor_right = pic.digital_io(1, 8, True) 8 | right_wheel_stopped = 938 9 | 10 | print "Running..." 11 | i = 0; 12 | while i < 10: 13 | i = i + 1 14 | # Print out line following diags 15 | if line_sensor_right.get(): 16 | pass 17 | -------------------------------------------------------------------------------- /src/tests/system/t119.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 119 15 | # Print Python traceback on exception 16 | # 17 | 18 | def divzero(n): 19 | print "In divzero" 20 | a = n/0 21 | 22 | def foo(): 23 | divzero(42) 24 | 25 | def bar(): 26 | foo() 27 | 28 | def baz(): 29 | bar() 30 | 31 | if ismain(): 32 | print "calling baz()" 33 | print "Expecting a ZeroDiv exception and traceback to print" 34 | baz() # expect exception and traceback 35 | -------------------------------------------------------------------------------- /src/tests/system/t132.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # Test for Issue #132: VM doesn't throw TypeError 15 | # when function has wrong number of arguments 16 | # 17 | 18 | def foo(n): 19 | return n * 1 20 | 21 | print "Expecting a TypeError" 22 | foo(1, 2) 23 | -------------------------------------------------------------------------------- /src/tests/system/t135.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 135 17 | * Code "if None" executes the positive case 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t135"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t135.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 135 15 | # Code "if None" executes the positive case 16 | # 17 | 18 | if None: 19 | assert False 20 | else: 21 | print "None is False. Passed." 22 | -------------------------------------------------------------------------------- /src/tests/system/t138.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 138 17 | * globals namespace isn't right 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t138"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t138.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 138 15 | # globals namespace isn't right 16 | # 17 | 18 | import dict 19 | 20 | print "dict.keys(globals()) = ", dict.keys(globals()) 21 | 22 | assert "__bi" in dict.keys(globals()) 23 | -------------------------------------------------------------------------------- /src/tests/system/t140.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 140 17 | * Create func module with introspection functions 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t140"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t140.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 140 15 | # Create func module with introspection functions 16 | # 17 | 18 | # This test requires that you build src/lib/func.py 19 | # The code is commented out so it won't cause a normal build to fail 20 | #import func 21 | 22 | 23 | #print "co_names: ", func.co_names(list) 24 | #print "co_consts: ", func.co_consts(list) 25 | -------------------------------------------------------------------------------- /src/tests/system/t141.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 141 17 | * String cache not handled by GC 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t141"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t142.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 142 17 | * list.append left a remnant on the stack 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t142"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t142.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 142 15 | # list.append left a remnant on the stack 16 | # 17 | 18 | import list 19 | 20 | l=[] 21 | rv = list.append(l, 42) 22 | 23 | assert rv == None 24 | -------------------------------------------------------------------------------- /src/tests/system/t147.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 147 17 | * Support Boolean type and True/False constants 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t147"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t150.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 150 17 | * Replace PmImgInfo_t to save RAM 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t150"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t150.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 150 15 | # Replace PmImgInfo_t to save RAM 16 | # 17 | 18 | import sys 19 | print sys.heap() 20 | -------------------------------------------------------------------------------- /src/tests/system/t153.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 153 17 | * Fix dict.clear() which fails to free the seglists 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t153"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t153.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 153 15 | # Fix dict.clear() which fails to free the seglists 16 | # 17 | 18 | import dict 19 | 20 | # Clear a dict and then make sure it can be used afterward 21 | d = {0:"zero", "one":1} 22 | dict.clear(d) 23 | 24 | d["zero"] = 0 25 | d[1] = "one" 26 | 27 | print d 28 | -------------------------------------------------------------------------------- /src/tests/system/t157.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 157 17 | * Support default args 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t157"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t158.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 158 17 | * Fix builtin sum() to support float 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t158"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t158.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2002 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | # 9 | # System Test 158 10 | # Fix builtin sum() to support float 11 | # 12 | 13 | 14 | l1 = [1, 2, 3] 15 | assert sum(l1) == 6 16 | print l1 17 | 18 | l2 = [1, 2, 3, 4.0] 19 | assert sum(l2) == 10.0 20 | print l2 21 | 22 | l3 = [1.0, 2.0, 3.0] 23 | assert sum(l3) == 6.0 24 | print l3 25 | 26 | # PyMite VM uses float type, not double; so this test passes here, 27 | # but would fail if run on the CPython VM. 28 | l4 = [1.1, 2.2, 3.3] 29 | assert sum(l4) != 6.6 # Rounding issue causes not-equal 30 | print l4 31 | 32 | l5 = [1.1, 2.2, 3.3, 4.4] 33 | assert sum(l5) == 11.0 34 | print l5 35 | -------------------------------------------------------------------------------- /src/tests/system/t160.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 160 17 | * Add support for string and tuple replication 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t160"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t161.c.expectfail: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 161 17 | * Improve filter for unsupported code 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | extern unsigned char usrlib_img[]; 24 | 25 | 26 | int main(void) 27 | { 28 | PmReturn_t retval; 29 | 30 | retval = pm_init(MEMSPACE_PROG, usrlib_img); 31 | PM_RETURN_IF_ERROR(retval); 32 | 33 | retval = pm_run((uint8_t *)"t161"); 34 | return (int)retval; 35 | } 36 | -------------------------------------------------------------------------------- /src/tests/system/t161.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 161 15 | # Improve filter for unsupported code 16 | # 17 | 18 | 19 | # Example of varargs 20 | def foo1(a, *b): 21 | return a+b 22 | 23 | 24 | # Example of keyword args 25 | def foo2(a, **kwb): 26 | return a+b[42] 27 | 28 | 29 | # Example of a generator 30 | def foo3(a): 31 | i = 0 32 | while 1: 33 | yield i 34 | i += a 35 | -------------------------------------------------------------------------------- /src/tests/system/t162.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 162 17 | * Implement builtin function dir() 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t162"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t162.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 162 15 | # Implement builtin function dir() 16 | # 17 | 18 | 19 | # Check dir on globals 20 | print "dir() = ",dir() 21 | assert dir() == ["__bi"] 22 | 23 | 24 | # Check dir on a function 25 | def foo(): 26 | pass 27 | d = dir() 28 | assert "__bi" in d and "foo" in d 29 | assert dir(foo) == [] 30 | 31 | foo.bar = "bar" 32 | assert dir(foo) == ["bar"] 33 | 34 | 35 | # Check dir on a module 36 | import sys 37 | d = dir() 38 | assert "sys" in d 39 | d = dir(sys) 40 | print "dir(sys) = ",d 41 | assert "heap" in d 42 | -------------------------------------------------------------------------------- /src/tests/system/t164.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 164 17 | * Add support for list comprehensions 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t164"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t174.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 174 17 | * Add support for keyword lambda 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t174"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t174.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 174 15 | # Add support for keyword lambda 16 | # 17 | 18 | dx = 42 19 | f1 = lambda x: x - dx 20 | print map(f1, range(5)) 21 | assert f1(0) == -42 22 | 23 | f2 = lambda x: x + dx 24 | print map(f2, range(5)) 25 | assert f2(0) == 42 26 | -------------------------------------------------------------------------------- /src/tests/system/t187.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 187 17 | * Remove module-level docstring 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t187"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t187.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 187 15 | # Remove module-level docstring 16 | # 17 | """NOT__NATIVE__ 18 | /* Inserted this so there is a module-level __doc__ string in the code object */ 19 | """ 20 | 21 | b = "__doc__" in globals() 22 | print "__doc__ in globals == ", b 23 | if b: 24 | print "len(__doc__) == ", len(globals()["__doc__"]) -------------------------------------------------------------------------------- /src/tests/system/t205.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 205 17 | * Add support for string format operation 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t205"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t207.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 207 17 | * Add support for the yield keyword 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t207"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t213.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 213 17 | * Add support for Python 2.6 bytecodes 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t213"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t213.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 213 15 | # Add support for Python 2.6 bytecodes 16 | # 17 | 18 | # None of tests below are able to create the bytecodes new to Python 2.6. 19 | # So the tests are commented out. 20 | 21 | # Test the *_TRUE_DIVIDE bytecodes 22 | #n = 4 23 | #d = 5 24 | #z = 0 25 | 26 | #assert n/d == 0.8 27 | #assert n//d == 0 28 | 29 | # The following should result in a ZeroDivisionError 30 | #r = n/z 31 | 32 | # Test the STORE_MAP bytecode 33 | #d = {} 34 | #d[0] = 0 35 | #d = {0: 0} 36 | -------------------------------------------------------------------------------- /src/tests/system/t232.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 232 17 | * Fix pmImgCreator so two classes can have same method name 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t232"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t232.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 232 15 | # Fix pmImgCreator so two classes can have same method name 16 | # An error during C compiling indicates a regression 17 | # 18 | 19 | 20 | class A(): 21 | def __init__(self,): 22 | """__NATIVE__ 23 | NATIVE_SET_TOS(PM_NONE); 24 | return PM_RET_OK; 25 | """ 26 | pass 27 | 28 | 29 | class B(): 30 | def __init__(self,): 31 | """__NATIVE__ 32 | NATIVE_SET_TOS(PM_NONE); 33 | return PM_RET_OK; 34 | """ 35 | pass 36 | -------------------------------------------------------------------------------- /src/tests/system/t233.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 233 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t233"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t234.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 234 17 | * Fix list comparisons 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t234"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t234.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 234 15 | # Fix list comparisons 16 | # 17 | 18 | assert not [] == [1,] 19 | assert not [] == [1,2,3] 20 | assert not [1,] == [] 21 | assert not [1,2,3] == [] 22 | 23 | assert [] != [1,] 24 | assert [] != [1,2,3] 25 | assert [1,] != [] 26 | assert [1,2,3] != [] 27 | 28 | assert [] == [] 29 | assert [0,1,2] == [0,1,2] 30 | assert [0,1,2] == [0,1,2][:] 31 | assert [0,1,2] == range(3) 32 | -------------------------------------------------------------------------------- /src/tests/system/t235.c.requires_xrange: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 235 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | extern unsigned char usrlib_img[]; 23 | 24 | 25 | int main(void) 26 | { 27 | PmReturn_t retval; 28 | 29 | retval = pm_init(MEMSPACE_PROG, usrlib_img); 30 | PM_RETURN_IF_ERROR(retval); 31 | 32 | retval = pm_run((uint8_t *)"t235"); 33 | return (int)retval; 34 | } 35 | -------------------------------------------------------------------------------- /src/tests/system/t235.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 235 15 | # 16 | 17 | import list 18 | 19 | 20 | l = [] 21 | for i in xrange(3): 22 | print i 23 | list.append(l, i) 24 | 25 | assert l == range(3) 26 | 27 | # Results in an AssertionError because the generator's StopIteration is 28 | # not caught; there is no SETUP_LOOP bytecode for this code 29 | # [x/2. for x in xrange(10) if x%2 == 0] 30 | -------------------------------------------------------------------------------- /src/tests/system/t236.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 236 17 | * Fix SLICE_0 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t236"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t236.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 236 15 | # Fix SLICE_0 16 | # 17 | 18 | s1 = "test" 19 | s2 = s1[:] 20 | assert s1 == s2 21 | assert id(s1) == id(s2) 22 | 23 | t1 = (1,2,3) 24 | t2 = t1[:] 25 | assert t1 == t2 26 | assert id(t1) == id(t2) 27 | 28 | l1 = [1,2,3] 29 | l2 = l1[:] 30 | assert l1 == l2 31 | assert id(l1) != id(l2) 32 | -------------------------------------------------------------------------------- /src/tests/system/t242.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 242 17 | * Add support for string concatenation 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t242"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t242.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 242 15 | # Add support for string concatenation 16 | # 17 | 18 | s1 = "test" 19 | s2 = "this" 20 | assert s1 + s2 == "testthis" 21 | 22 | s3 = "" 23 | assert s1 + s3 == s1 24 | assert s3 + s1 == s1 25 | 26 | assert s1 + "\0" == "test\0" 27 | assert "\0" + s1 == "\0test" 28 | 29 | print "String concatenation " + s1 + " passes" 30 | -------------------------------------------------------------------------------- /src/tests/system/t243.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 243 17 | * Fix cases where string contains an embedded null 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t243"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t243.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 243 15 | # Fix cases where string contains an embedded null 16 | # 17 | 18 | s1 = "\0" 19 | s2 = "a" + s1 20 | s3 = s2 + "a" 21 | 22 | assert s2 == "a\0" 23 | assert s3 == "a\0a" 24 | 25 | s2 = s1 + "a" 26 | s3 = s2 + "\0" 27 | 28 | assert s2 == "\0a" 29 | assert s3 == "\0a\0" 30 | 31 | s2 = "let's \0 try" + s1 + "something else\0" 32 | assert s2 == "let's \0 try\0something else\0" 33 | -------------------------------------------------------------------------------- /src/tests/system/t244.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 244 17 | * Add support for backtick operation (UNARY_CONVERT) 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t244"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t244.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 244 15 | # Add support for backtick operation (UNARY_CONVERT) 16 | # 17 | 18 | x = 4 19 | filename = "A:/log" + `x` + ".log" 20 | assert filename == "A:/log4.log" 21 | 22 | y = 3.14 23 | saying = `y` + " is not PI." 24 | print saying 25 | assert saying == "3.140000 is not PI." 26 | 27 | print "Backtick passes" 28 | -------------------------------------------------------------------------------- /src/tests/system/t245.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 245 17 | * Fix endian issue (again) 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t245"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t245.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2009 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 245 15 | # Fix endian issue (again) 16 | # 17 | 18 | x = 1.1 19 | print "1.1 = ", x 20 | 21 | assert x + x == 2.2 22 | print "1.1 + 1.1 == ", x+x, " Endian test passes." 23 | -------------------------------------------------------------------------------- /src/tests/system/t248.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 248 15 | # Eliminate remnants of unused OBJ_TYPE_EXN 16 | # 17 | 18 | # Expect an AssertionError (0xE4) 19 | # Receiving a TypeError (0xED) is a regression 20 | 21 | print "Expect AssertionError:" 22 | assert 0 == 1 23 | -------------------------------------------------------------------------------- /src/tests/system/t256.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 256 17 | * Add support for closures 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t256"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t258.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 258 15 | # Fix exception thrown when iterating over class instance without next() method 16 | # 17 | 18 | 19 | class C(): 20 | pass 21 | 22 | c = C() 23 | 24 | print "Expect TypeError:" 25 | for i in c: 26 | print i 27 | -------------------------------------------------------------------------------- /src/tests/system/t259.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 259 17 | * Add filter() function to builtins 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t259"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t281.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 281 17 | * Fix float comparisons 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t281"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t281.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2010 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | # 9 | # System Test 281 10 | # Fix float comparisons 11 | # 12 | 13 | a = 3.4e-15 14 | b = 3.5e-15 15 | print "a == b ?", a == b 16 | assert not (a == b) 17 | assert a != b 18 | -------------------------------------------------------------------------------- /src/tests/system/t284.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 284 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t284"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t289.c.postponed_until_issue_#97: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009, 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 289 17 | * Create bytearray datatype 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | extern unsigned char usrlib_img[]; 24 | 25 | 26 | int main(void) 27 | { 28 | PmReturn_t retval; 29 | 30 | retval = pm_init(MEMSPACE_PROG, usrlib_img); 31 | PM_RETURN_IF_ERROR(retval); 32 | 33 | retval = pm_run((uint8_t *)"t289"); 34 | return (int)retval; 35 | } 36 | -------------------------------------------------------------------------------- /src/tests/system/t290.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 290 17 | * Add wait() to sys module 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t290"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t290.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 290 15 | # Add wait() to sys module 16 | # 17 | 18 | import sys 19 | 20 | # Really short waits 21 | sys.wait(-1) 22 | sys.wait(0) 23 | sys.wait(1) 24 | 25 | # Longer wait 26 | print "Waiting 3 secs..." 27 | sys.wait(3000) 28 | print "done." 29 | -------------------------------------------------------------------------------- /src/tests/system/t291.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2003, 2006, 2007, 2009, 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 291 17 | * Fix GC so base classes are not collected 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t291"); 37 | return (int)retval; 38 | } 39 | -------------------------------------------------------------------------------- /src/tests/system/t321.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 321 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t321"); 36 | C_ASSERT((int)retval == PM_RET_EX_TYPE); 37 | if (retval == PM_RET_EX_TYPE) return (int)PM_RET_OK; 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t321.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 321 15 | # 16 | 17 | print "Generator with wrong num args, Expect TypeError" 18 | 19 | 20 | def gen(o): 21 | yield o 22 | 23 | f = gen() 24 | print f.next() 25 | -------------------------------------------------------------------------------- /src/tests/system/t329.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 329 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t329"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t329.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 329 15 | # 16 | 17 | from sys import gc 18 | 19 | 20 | def iter(s): 21 | for i in s: 22 | yield i 23 | 24 | 25 | ch = iter("abcd") 26 | 27 | 28 | def i(): 29 | print ch.next() 30 | gc() 31 | 32 | i() 33 | i() 34 | i() 35 | -------------------------------------------------------------------------------- /src/tests/system/t334.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 334 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t334"); 36 | C_ASSERT((int)retval == PM_RET_EX_TYPE); 37 | if (retval == PM_RET_EX_TYPE) return (int)PM_RET_OK; 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t334.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 334 15 | # 16 | 17 | print "hex(42) == %x" % 42 18 | 19 | a = 42 20 | s = "%x" % a 21 | print s 22 | assert s == "2a" 23 | 24 | S = "%X" % a 25 | print S 26 | assert S == "2A" 27 | 28 | # For now, expect TypeError, in future, convert float to int and expect it to work 29 | print "Expect TypeError" 30 | b = 3.14 31 | p = "%x" % b 32 | assert p == "3" -------------------------------------------------------------------------------- /src/tests/system/t347.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 347 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t347a"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t347a.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 347 15 | # 16 | 17 | import string 18 | from sys import gc 19 | from t347b import * 20 | 21 | 22 | print bar1() 23 | print bar2() 24 | gc() 25 | print 'did gc' 26 | print bar1() 27 | print bar2() 28 | -------------------------------------------------------------------------------- /src/tests/system/t347b.py: -------------------------------------------------------------------------------- 1 | def bar1(): 2 | """__NATIVE__ 3 | PmReturn_t retval = PM_RET_OK; 4 | 5 | /* If wrong number of args, raise TypeError */ 6 | if (NATIVE_GET_NUM_ARGS() != 0) 7 | { 8 | PM_RAISE(retval, PM_RET_EX_TYPE); 9 | return retval; 10 | } 11 | 12 | NATIVE_SET_TOS(PM_NONE); 13 | return retval; 14 | """ 15 | pass 16 | 17 | def bar2(): 18 | return bar1() 19 | -------------------------------------------------------------------------------- /src/tests/system/t349.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 349 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t349"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t349.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2010 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | # 9 | # System Test 349 10 | # 11 | 12 | d1 = {} 13 | d1[1] = "one" 14 | 15 | d2 = {} 16 | d2[2] = "two" 17 | 18 | 19 | import dict 20 | rv = dict.update(d1, d2) 21 | 22 | assert rv == None 23 | assert d1 == {1:"one", 2:"two"} 24 | assert d2 == {2:"two"} 25 | -------------------------------------------------------------------------------- /src/tests/system/t350.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 350 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t350a"); 36 | C_ASSERT((int)retval == PM_RET_EX_TYPE); 37 | if (retval == PM_RET_EX_NAME) return (int)PM_RET_OK; 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t350a.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 350 15 | # 16 | 17 | from t350b import * 18 | 19 | print "Expect NameError" 20 | print _foo 21 | -------------------------------------------------------------------------------- /src/tests/system/t350b.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 350 15 | # 16 | 17 | _foo = "foo" -------------------------------------------------------------------------------- /src/tests/system/t352.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 352 17 | * Fix modulus for negative integers 18 | */ 19 | 20 | #include "pm.h" 21 | 22 | 23 | #define HEAP_SIZE 0x2000 24 | 25 | extern unsigned char usrlib_img[]; 26 | 27 | 28 | int main(void) 29 | { 30 | uint8_t heap[HEAP_SIZE]; 31 | PmReturn_t retval; 32 | 33 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 34 | PM_RETURN_IF_ERROR(retval); 35 | 36 | retval = pm_run((uint8_t *)"t352"); 37 | if (retval == PM_RET_EX_OFLOW) return (int)PM_RET_OK; 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t352.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2010 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | # 9 | # System Test 352 10 | # Fix modulus with negative integers 11 | # 12 | 13 | a = 2 14 | n = 3 15 | 16 | print " 2 % 3 in pymite:", (a % n), " and in cpython:", 2 17 | print " (-2) % 3 in pymite:", ((-a) % n), " and in cpython:", 1 18 | print " 2 % (-3) in pymite:", (a % (-n)), " and in cpython:", -1 19 | print "(-2) % (-3) in pymite:", ((-a) % (-n)), " and in cpython:", -2 20 | 21 | assert (a % n) == 2 22 | assert ((-a) % n) == 1 23 | assert (a % (-n)) == -1 24 | assert ((-a) % (-n)) == -2 25 | 26 | assert 12 % 1 == 0 27 | assert 12 % -1 == 0 28 | 29 | # Division 30 | 31 | assert -3 / 4 == -1 32 | assert -4 / 3 == -2 33 | assert 12 / 1 == 12 34 | assert 12 / -1 == -12 35 | 36 | 37 | import sys 38 | assert (-sys.maxint-1) % -1 == 0 39 | 40 | print "Expect OverflowError" 41 | assert (-sys.maxint-1) / -1 -------------------------------------------------------------------------------- /src/tests/system/t370.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 370 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t370"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t370.py: -------------------------------------------------------------------------------- 1 | # 2 | # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 3 | # Copyright 2010 Dean Hall. All rights reserved. 4 | # PyMite is offered through one of two licenses: commercial or open-source. 5 | # See the LICENSE file at the root of this package for licensing details. 6 | # 7 | 8 | # 9 | # System Test 370 10 | # 11 | 12 | 13 | import string 14 | 15 | # Create a string longer than 256 bytes to expose a too-small datatype in 16 | # src/lib/string.py's find() 17 | s = "0123456789012345678901234567890123456789" \ 18 | "0123456789012345678901234567890123456789" \ 19 | "0123456789012345678901234567890123456789" \ 20 | "0123456789012345678901234567890123456789" \ 21 | "0123456789012345678901234567890123456789" \ 22 | "0123456789012345678901234567890123456789" \ 23 | "0123456789012345678901234567890123456789" \ 24 | "A" 25 | 26 | loc_A = string.find(s, "A") 27 | assert loc_A == len(s) - 1 28 | -------------------------------------------------------------------------------- /src/tests/system/t374.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 374 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t374"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t376.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 376 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t376"); 36 | C_ASSERT((int)retval == PM_RET_EX_TYPE); 37 | if (retval == PM_RET_EX_TYPE) return (int)PM_RET_OK; 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t376.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 376 15 | # Regression will show "TypeError detected by seq.c:254" 16 | # because it's trying to iterate over a dict. 17 | # 18 | 19 | 20 | d = {0:None, 1:"one", 2:"two"} 21 | 22 | for i in d: 23 | assert i in d 24 | 25 | k1,k2,k3 = d 26 | assert k1 in d and k2 in d and k3 in d 27 | 28 | s = sum(d) 29 | assert s == 3 30 | 31 | # Requires HAVE_BYTEARRAY 32 | #b = bytearray(range(10)) 33 | #assert sum(b) == 45 34 | -------------------------------------------------------------------------------- /src/tests/system/t377.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2010 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 377 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t377"); 36 | C_ASSERT((int)retval == PM_RET_EX_TYPE); 37 | if (retval == PM_RET_EX_TYPE) return (int)PM_RET_OK; 38 | return (int)retval; 39 | } 40 | -------------------------------------------------------------------------------- /src/tests/system/t377.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2010 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 377 15 | # 16 | 17 | import dict 18 | 19 | 20 | d = {0:None} 21 | 22 | r1 = dict.has_key(d, 0) 23 | r2 = dict.has_key(d, None) 24 | 25 | # Must use "is" because 0 == False and 1 == True 26 | assert r1 is True 27 | assert r2 is False 28 | -------------------------------------------------------------------------------- /src/tests/system/t378.c: -------------------------------------------------------------------------------- 1 | /* 2 | # This file is Copyright 2011 Dean Hall. 3 | # 4 | # This file is part of the Python-on-a-Chip program. 5 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 7 | # 8 | # Python-on-a-Chip is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 12 | # is seen in the file COPYING up one directory from this. 13 | */ 14 | 15 | /** 16 | * System Test 378 17 | */ 18 | 19 | #include "pm.h" 20 | 21 | 22 | #define HEAP_SIZE 0x2000 23 | 24 | extern unsigned char usrlib_img[]; 25 | 26 | 27 | int main(void) 28 | { 29 | uint8_t heap[HEAP_SIZE]; 30 | PmReturn_t retval; 31 | 32 | retval = pm_init(heap, HEAP_SIZE, MEMSPACE_PROG, usrlib_img); 33 | PM_RETURN_IF_ERROR(retval); 34 | 35 | retval = pm_run((uint8_t *)"t378d"); 36 | return (int)retval; 37 | } 38 | -------------------------------------------------------------------------------- /src/tests/system/t378d.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2011 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 378 15 | # 16 | 17 | 18 | from t378e import the_list 19 | import t378f 20 | 21 | print "the_list[0] =", the_list[0] 22 | 23 | assert the_list[0] == 41 -------------------------------------------------------------------------------- /src/tests/system/t378e.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2011 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 378 15 | # 16 | 17 | 18 | the_list = [40] 19 | -------------------------------------------------------------------------------- /src/tests/system/t378f.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2011 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 378 15 | # 16 | 17 | 18 | from t378e import the_list 19 | 20 | the_list[0] += 1 21 | -------------------------------------------------------------------------------- /src/tests/system/t380.py: -------------------------------------------------------------------------------- 1 | # This file is Copyright 2011 Dean Hall. 2 | # 3 | # This file is part of the Python-on-a-Chip program. 4 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 5 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 6 | # 7 | # Python-on-a-Chip is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 11 | # is seen in the file COPYING up one directory from this. 12 | 13 | # 14 | # System Test 380 15 | # 16 | 17 | 18 | import sys 19 | sys.gc() 20 | -------------------------------------------------------------------------------- /src/tools/pmGenPmFeatures.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This file is Copyright 2010 Dean Hall. 4 | # 5 | # This file is part of the Python-on-a-Chip program. 6 | # Python-on-a-Chip is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 8 | # 9 | # Python-on-a-Chip is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 13 | # is seen in the file COPYING up one directory from this. 14 | 15 | """ 16 | Generates C definitions on stdout for all features in the input set to True 17 | 18 | Expects name of a pmfeatures.py file as the only argument. 19 | """ 20 | 21 | 22 | import sys, time 23 | 24 | 25 | execfile(sys.argv[1]) 26 | sys.stdout.write("/* Automatically generated by %s on %s. DO NOT EDIT. */\n" 27 | % (sys.argv[0], time.ctime(time.time()))) 28 | map(sys.stdout.write, 29 | ("#define %s\n" % s for s in PM_FEATURES.keys() if PM_FEATURES[s])) 30 | -------------------------------------------------------------------------------- /src/vm/SConscript: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | Import("env", "vars") 5 | 6 | SOURCES = Glob("*.c") 7 | PMSTDLIB_SOURCES = ["../lib/list.py", 8 | "../lib/dict.py", 9 | "../lib/__bi.py", 10 | "../lib/sys.py", 11 | "../lib/string.py",] 12 | if env["IPM"] == True: 13 | PMSTDLIB_SOURCES.append("../lib/ipm.py") 14 | 15 | 16 | img_sources = Command(["pmstdlib_img.c", "pmstdlib_nat.c"], [PMSTDLIB_SOURCES], 17 | "%s src/tools/pmImgCreator.py -f src/platform/%s/pmfeatures.py -c -s " \ 18 | "-o src/vm/pmstdlib_img.c --native-file=src/vm/pmstdlib_nat.c $SOURCES" \ 19 | % (sys.executable, vars.args["PLATFORM"])) 20 | if sys.platform != "win32": 21 | env['ARFLAGS'] = "rcs" 22 | lib = env.Library("pmvm_%s" % vars.args["PLATFORM"], SOURCES + img_sources) 23 | env.Precious(lib) 24 | 25 | 26 | Return("lib") 27 | -------------------------------------------------------------------------------- /src/vm/fileid.txt: -------------------------------------------------------------------------------- 1 | ===== ======================================= 2 | ID FILE 3 | ===== ======================================= 4 | 0x01 codeobj.c 5 | 0x02 dict.c 6 | 0x03 frame.c 7 | 0x04 func.c 8 | 0x05 global.c 9 | 0x06 heap.c 10 | 0x07 img.c 11 | 0x08 int.c 12 | 0x09 interp.c 13 | 0x0A pmstdlib_nat.c 14 | 0x0B list.c 15 | 0x0C main.c 16 | 0x0D mem.c 17 | 0x0E module.c 18 | 0x0F obj.c 19 | 0x10 seglist.c 20 | 0x11 sli.c 21 | 0x12 strobj.c 22 | 0x13 tuple.c 23 | 0x14 seq.c 24 | 0x15 pm.c 25 | 0x16 thread.c 26 | 0x17 float.c 27 | 0x18 class.c 28 | 0x19 bytearray.c 29 | ----- --------------------------------------- 30 | 0x70 RESERVED FOR PLATFORM-SPECIFIC FILES 31 | 0x7F 32 | ----- --------------------------------------- 33 | 0x90 utest.c 34 | 0x92 ut_dict.c 35 | 0x9B ut_list.c 36 | ===== ======================================= 37 | --------------------------------------------------------------------------------