Giter Site home page Giter Site logo

compilation_ucbl_2016's Introduction

This code is not interesing if you are not working with me on that course ;)

See the file test.py for all tests.

Tips

You can add the environment variable FAST to generate faster (but less exhaustives) tests.

  • no FAST : exhaustives tests, can be slow (2 minutes on my computer)
  • FAST=1 : one case per testcase, quick (<1s), but not exhaustive
  • FAST=10 : quick (2s), only 10 cases per testcase, but usually enough

Usage

The PYTHONPATH environment variable must be set to the path of the MyMuCodeGenVisitor.py file.

Run and get the assembly for a mu file, for example, exemple.mu :

a = 0;
n = 3;
while(a < n)
{
   a = a + 1;
}
$ PYTHONPATH=../MIF08_TP4/StudFilesTP4 python2 test_utils.py exemple.mu 
assign statement, rightexpression is:
(expr (atom 0))
assign statement, rightexpression is:
(expr (atom 3))
assign statement, rightexpression is:
(expr (expr (atom a)) + (expr (atom 1)))
--variables to register map--
a-->temp_2
n-->temp_4
And(dr='temp_1', sr1='temp_1', sr2orimm7=0)
Add(dr='temp_1', sr1='temp_1', sr2orimm7=0)
And(dr='temp_2', sr1='temp_2', sr2orimm7=0)
Add(dr='temp_2', sr1='temp_2', sr2orimm7='temp_1')
And(dr='temp_3', sr1='temp_3', sr2orimm7=0)
Add(dr='temp_3', sr1='temp_3', sr2orimm7=3)
And(dr='temp_4', sr1='temp_4', sr2orimm7=0)
Add(dr='temp_4', sr1='temp_4', sr2orimm7='temp_3')
Label(label='l_while_begin_1')
And(dr='temp_5', sr1='temp_5', sr2orimm7=0)
Not(dr='temp_5', sr1='temp_4')
Add(dr='temp_5', sr1='temp_5', sr2orimm7=1)
Add(dr='temp_6', sr1='temp_2', sr2orimm7='temp_5')
Br(label='l_cond_neg_2', s='n')
And(dr='temp_7', sr1='temp_7', sr2orimm7=0)
Br(label='l_cond_end_2', s='')
Label(label='l_cond_neg_2')
And(dr='temp_7', sr1='temp_7', sr2orimm7=0)
Add(dr='temp_7', sr1='temp_7', sr2orimm7=1)
Label(label='l_cond_end_2')
Br(label='l_while_end_1', s='z')
And(dr='temp_8', sr1='temp_8', sr2orimm7=0)
Add(dr='temp_8', sr1='temp_8', sr2orimm7=1)
Add(dr='temp_9', sr1='temp_2', sr2orimm7='temp_8')
And(dr='temp_2', sr1='temp_2', sr2orimm7=0)
Add(dr='temp_2', sr1='temp_2', sr2orimm7='temp_9')
Br(label='l_while_begin_1', s='')
Label(label='l_while_end_1')
{'temp_9': 3, 'temp_8': 1, 'temp_5': -3, 'temp_4': 3, 'temp_7': 0, 'temp_6': 0, 'temp_1': 0, 'temp_3':

Runs the test for one student :

$ FAST=10 PYTHONPATH=../MIF08_TP4/StudFilesTP4 python2 -m unittest test
..........................
----------------------------------------------------------------------
Ran 26 tests in 11.285s

OK

results are stored inside 'result.csv'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.