source: proto/pablo/src/compiler/lang/pabloS/Builtins2CPP.java @ 2757

Last change on this file since 2757 was 2757, checked in by ksherdy, 6 years ago

Renamed package from pablo to pabloS.

File size: 1.8 KB
Line 
1package compiler.lang.pabloS;
2
3import java.util.HashMap;
4import java.util.Map;
5
6public class Builtins2CPP extends Builtins2Lang {
7
8        private static Map<Builtins, String> pablo2CPPCode;
9       
10    static {
11       
12        pablo2CPPCode = new HashMap<Builtins, String>();
13       
14        pablo2CPPCode.put(Builtins.ADVANCE,"BitBlock_advance_ci_co");
15        pablo2CPPCode.put(Builtins.SCANTOFIRST, "BitBlock_scantofirst");
16        pablo2CPPCode.put(Builtins.SCANTHRU, "BitBlock_scanthru_ci_co");
17        pablo2CPPCode.put(Builtins.SCANTO, "BitBlock_scanto_ci_co");
18        pablo2CPPCode.put(Builtins.ADVANCETHENSCANTHRU, "BitBlock_advance_then_scanthru");
19        pablo2CPPCode.put(Builtins.ADVANCETHENSCANTO, "BitBlock_advance_then_scanto");
20        pablo2CPPCode.put(Builtins.SPANUPTO, "BitBlock_span_upto");
21        pablo2CPPCode.put(Builtins.INCLUSIVESPAN, "BitBlock_inclusive_span");
22        pablo2CPPCode.put(Builtins.EXCLUSIVESPAN, "BitBlock_exclusive_span");   
23
24        pablo2CPPCode.put(Builtins.ADVANCE32, "BitBlock_advance_n_<32>");
25        pablo2CPPCode.put(Builtins.ADVANCEN, "BitBlock_advance_n_<%d>");
26
27        pablo2CPPCode.put(Builtins.ATEOF, "atEOF");
28        pablo2CPPCode.put(Builtins.INFILE, "inFile"); 
29        pablo2CPPCode.put(Builtins.ASSERTZERO, "assert_0_error");       
30        pablo2CPPCode.put(Builtins.EOFMASK, "EOF_mask");
31       
32        pablo2CPPCode.put(Builtins.PRINTBITBLOCK, "print_register<BitBlock>");
33        pablo2CPPCode.put(Builtins.ASSERTBITBLOCKALIGN, "ASSERT_BITBLOCK_ALIGN");       
34               
35        for(Builtins builtin : Builtins.values()) {
36                if(!pablo2CPPCode.containsKey(builtin)) {
37                                throw new RuntimeException("Builtin to CPP code mapping unimplemented in :" + Builtins2CPP.class.getSimpleName());
38                }
39        }
40    }
41   
42        public String getCode(Builtins builtin) {                       
43                return pablo2CPPCode.get(builtin);
44        }
45       
46}
Note: See TracBrowser for help on using the repository browser.