Changeset 3816


Ignore:
Timestamp:
Apr 12, 2014, 9:52:25 PM (4 years ago)
Author:
ksherdy
Message:

Moved carrySet from s2k to b2k.

Location:
proto/s2k/trunk/framework/src/toolchain/s2k/lang
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/S2KBuiltin.java

    r3811 r3816  
     1/*
     2 * Builtin Interface.
     3 *
     4 * @author Ken Herdy <ksherdy at sfu dot ca>
     5 *
     6 */
     7
    18package toolchain.s2k.lang;
    29
    3 import java.util.HashMap;
    4 import java.util.Map;
     10public interface S2KBuiltin {
     11                       
     12        /** Yields a printable string for information about this builtin.
     13         * Use this rather than toString() if you want an abbreviated string.
     14         *
     15         * @return string representation of builtin.
     16         */
     17        public String infoString();
     18               
     19        /** Returns the builtin with any builtin variables filled in with their values.
     20         */
     21        public S2KBuiltin getConcreteBuiltin();
     22       
     23}
    524
    6 import toolchain.s2k.lang.S2KBuiltinTranslator;
    7 import toolchain.s2k.lang.signatures.FunctionSignature;
    8 import static toolchain.s2k.lang.S2KBuiltinTranslator.*;
    9 import static toolchain.s2k.lang.signatures.SignatureShorthand.*;
    10 
    11 public enum S2KBuiltin {
    12     FLOW_ADVANCE(               "Advance",             CarryType.SingleBit, CARRY_TRANSLATION,                 sig_S_S()  ), // BuiltinCallUtil, CombineAdvances
    13     FLOW_SCAN_TO_FIRST(         "ScanToFirst",         CarryType.SingleBit, SCANTO_FIRST_TRANSLATION,          sig_S_S(), InitialValue.One ),
    14     FLOW_SCAN_THRU(             "ScanThru",            CarryType.SingleBit, CARRY_TRANSLATION,                 sig_SS_S() ), // BuiltinTranslator
    15     FLOW_SCAN_TO(               "ScanTo",              CarryType.SingleBit, SCANTO_TRANSLATION,                sig_SS_S() ),
    16     FLOW_SPAN_UP_TO(            "SpanUpTo",            CarryType.SingleBit, CARRY_TRANSLATION,                 sig_SS_S() ),
    17     FLOW_INCLUSIVE_SPAN(        "InclusiveSpan",       CarryType.SingleBit, CARRY_TRANSLATION,                 sig_SS_S() ),
    18     FLOW_EXCLUSIVE_SPAN(        "ExclusiveSpan",       CarryType.SingleBit, CARRY_TRANSLATION,                 sig_SS_S() ),
    19     FLOW_ADVANCE_THEN_SCAN_THRU("AdvanceThenScanThru", CarryType.SingleBit, CARRY_TRANSLATION,                 sig_SS_S() ),
    20     FLOW_ADVANCE_THEN_SCAN_TO(  "AdvanceThenScanTo",   CarryType.SingleBit, ADVANCE_THEN_SCANTO_TRANSLATION,   sig_SS_S()  ), // BuiltinTranslator
    21     FLOW_ADVANCE_N(                     "AdvanceN",  CarryType.NBits,    ADVANCEN_TRANSLATION, sig_SI_S() ), // AdvNCounterVisitor   
    22 
    23     FLOW_MASK(                          "Mask",      CarryType.None, MASK_TRANSLATION,            sig_II_S() ), // visitors.carry.Counter   
    24     FLOW_AT_EOF(                        "atEOF",     CarryType.None, ATEOF_TRANSLATION,           sig_S_S()  ),
    25     FLOW_IN_FILE(                       "inFile",    CarryType.None, INFILE_TRANSLATION,          sig_S_S()  ),
    26     FLOW_ASSERT_ZERO(                   "assert_0",  CarryType.None, ASSERT_ZERO_TRANSLATION,     sig_ST_V() ), // surroundAssert0sWithIfs     
    27     NULL_BUILTIN(                               "NULL",      CarryType.None, CARRY_TRANSLATION,           sig_V_V()  );
    28 
    29     public enum CarryType{      SingleBit,     
    30                                                         NBits,         
    31                                                         IntValue,       
    32                                                         None };
    33     public enum InitialValue{ Zero, One };
    34    
    35     public static final String BUILTIN_PACKAGE_NAME = "flow";
    36    
    37     private final CarryType carryType;
    38     private final InitialValue initialValue;
    39         private final String name;
    40         private final FunctionSignature signature;
    41         private final S2KBuiltinTranslator translator;
    42 
    43         private S2KBuiltin(String name, CarryType carryType, S2KBuiltinTranslator translator, FunctionSignature signature, InitialValue initialValue) {
    44 
    45                 this.name = name;
    46                 this.carryType = carryType;
    47                 this.translator = translator;
    48                 this.signature = signature;
    49                 this.initialValue = initialValue;
    50         }
    51 
    52         private S2KBuiltin(String name, CarryType carryType, S2KBuiltinTranslator translator, FunctionSignature signature) {
    53                 this(name, carryType, translator, signature, InitialValue.Zero);
    54         }
    55        
    56         /////////////////////////////////////////////////////////////////
    57         // forName(String)  mechanism
    58         /////////////////////////////////////////////////////////////////
    59         static private Map<String, S2KBuiltin> builtinForName = new HashMap<String, S2KBuiltin>();
    60         static {
    61                 for(S2KBuiltin builtin: values()) {
    62                         builtinForName.put(builtin.fullyQualifiedName(), builtin);
    63                 }
    64         }
    65         public static S2KBuiltin forName(String fullyQualifiedName) {
    66                 if(builtinForName.containsKey(fullyQualifiedName)) {
    67                         return builtinForName.get(fullyQualifiedName);
    68                 }
    69                 return NULL_BUILTIN;
    70         }
    71        
    72         /////////////////////////////////////////////////////////////////
    73         // queries
    74         /////////////////////////////////////////////////////////////////
    75         public String fullyQualifiedName () { return packageName() + "." + this.baseName() ;}
    76         public String packageName() { return  this.name().toLowerCase().split("_")[0]; }
    77         public String baseName() { return this.name; }
    78         public final CarryType getCarryType() { return carryType; }
    79         public final boolean isCarryNone() { return carryType == CarryType.None; }
    80         public final boolean isCarry1() { return carryType == CarryType.SingleBit; }
    81         public final boolean isCarryN() { return carryType == CarryType.NBits; }
    82         public final boolean isCarryIntValue() { return carryType == carryType.IntValue; }
    83         public final S2KBuiltinTranslator getTranslator() { return translator; }
    84         public final InitialValue getInitialValue() { return initialValue; }
    85         public final int intInitialValue() { return (initialValue == InitialValue.One) ? 1 : 0; }
    86         public FunctionSignature getSignature() { return signature; }
    87 
    88 }
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/S2KBuiltin2C.java

    r3811 r3816  
    11package toolchain.s2k.lang;
     2
     3/*
     4 * KH: Refactor to translate s2k2b2k and then b2k2CLang or b2k2CPPLang.
     5 */
    26
    37import java.util.HashMap;
     
    610public class S2KBuiltin2C extends S2KBuiltinEncoder {
    711       
    8         private static Map<S2KBuiltin, String> s2k2CCode;
     12        private static Map<S2KBuiltins, String> s2k2CCode;
    913       
    1014    static {
    1115       
    12         s2k2CCode = new HashMap<S2KBuiltin, String>();
     16        s2k2CCode = new HashMap<S2KBuiltins, String>();
    1317       
    14         s2k2CCode.put(S2KBuiltin.FLOW_ADVANCE,                  "pablo_blk_Advance");
    15         s2k2CCode.put(S2KBuiltin.FLOW_SCAN_TO_FIRST,            "pablo_blk_ScanToFirst");
    16         s2k2CCode.put(S2KBuiltin.FLOW_SCAN_THRU,                "pablo_blk_ScanThru");
    17         s2k2CCode.put(S2KBuiltin.FLOW_SCAN_TO,                  "pablo_blk_ScanTo");
    18         s2k2CCode.put(S2KBuiltin.FLOW_ADVANCE_THEN_SCAN_THRU,   "pablo_blk_AdvanceThenScanThru");
    19         s2k2CCode.put(S2KBuiltin.FLOW_ADVANCE_THEN_SCAN_TO,     "pablo_blk_AdvanceThenScanTo");
    20         s2k2CCode.put(S2KBuiltin.FLOW_SPAN_UP_TO,               "pablo_blk_SpanUpTo");
    21         s2k2CCode.put(S2KBuiltin.FLOW_INCLUSIVE_SPAN,           "pablo_blk_InclusiveSpan");
    22         s2k2CCode.put(S2KBuiltin.FLOW_EXCLUSIVE_SPAN,           "pablo_blk_ExclusiveSpan");   
    23         s2k2CCode.put(S2KBuiltin.FLOW_ADVANCE_N,                "pablo_blk_Advance_n_<%s>");
    24         s2k2CCode.put(S2KBuiltin.FLOW_MASK,                     "Mask");
    25         s2k2CCode.put(S2KBuiltin.FLOW_AT_EOF,                   "atEOF");
    26         s2k2CCode.put(S2KBuiltin.FLOW_IN_FILE,                  "inFile");
    27         s2k2CCode.put(S2KBuiltin.FLOW_ASSERT_ZERO,              "assert_0_error");     
    28         s2k2CCode.put(S2KBuiltin.NULL_BUILTIN,                          "null_builtin_error");
     18        s2k2CCode.put(S2KBuiltins.FLOW_ADVANCE,                         "pablo_blk_Advance");
     19        s2k2CCode.put(S2KBuiltins.FLOW_SCAN_TO_FIRST,                   "pablo_blk_ScanToFirst");
     20        s2k2CCode.put(S2KBuiltins.FLOW_SCAN_THRU,                       "pablo_blk_ScanThru");
     21        s2k2CCode.put(S2KBuiltins.FLOW_SCAN_TO,                         "pablo_blk_ScanTo");
     22        s2k2CCode.put(S2KBuiltins.FLOW_ADVANCE_THEN_SCAN_THRU,          "pablo_blk_AdvanceThenScanThru");
     23        s2k2CCode.put(S2KBuiltins.FLOW_ADVANCE_THEN_SCAN_TO,            "pablo_blk_AdvanceThenScanTo");
     24        s2k2CCode.put(S2KBuiltins.FLOW_SPAN_UP_TO,                      "pablo_blk_SpanUpTo");
     25        s2k2CCode.put(S2KBuiltins.FLOW_INCLUSIVE_SPAN,                  "pablo_blk_InclusiveSpan");
     26        s2k2CCode.put(S2KBuiltins.FLOW_EXCLUSIVE_SPAN,                  "pablo_blk_ExclusiveSpan");   
     27        s2k2CCode.put(S2KBuiltins.FLOW_ADVANCE_N,                       "pablo_blk_Advance_n_<%s>");
     28        s2k2CCode.put(S2KBuiltins.FLOW_MASK,                            "Mask");
     29        s2k2CCode.put(S2KBuiltins.FLOW_AT_EOF,                          "atEOF");
     30        s2k2CCode.put(S2KBuiltins.FLOW_IN_FILE,                         "inFile");
     31        s2k2CCode.put(S2KBuiltins.FLOW_ASSERT_ZERO,                     "assert_0_error");     
     32        s2k2CCode.put(S2KBuiltins.NULL_BUILTIN,                         "null_builtin_error");
    2933
    30         for(S2KBuiltin builtin : S2KBuiltin.values()) {
     34        for(S2KBuiltins builtin : S2KBuiltins.values()) {
    3135                if(!s2k2CCode.containsKey(builtin)) {
    3236                                throw new RuntimeException("S2K builtin to C mapping not unimplemented in :" + S2KBuiltin2C.class.getSimpleName());
     
    3640
    3741        @Override
    38         public String getName(S2KBuiltin builtin) {
     42        public String getName(S2KBuiltins builtin) {
    3943                return s2k2CCode.get(builtin);
    4044        }
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/S2KBuiltin2CPP.java

    r3811 r3816  
    1212public class S2KBuiltin2CPP extends S2KBuiltinEncoder {
    1313
    14         private static Map<S2KBuiltin, String> s2k2CPPCode;
     14        private static Map<S2KBuiltins, String> s2k2CPPCode;
    1515       
    1616    static {
    1717       
    18         s2k2CPPCode = new HashMap<S2KBuiltin, String>();
     18        s2k2CPPCode = new HashMap<S2KBuiltins, String>();
    1919       
    20         s2k2CPPCode.put(S2KBuiltin.FLOW_ADVANCE,                   "pablo_blk_Advance");
    21         s2k2CPPCode.put(S2KBuiltin.FLOW_SCAN_TO_FIRST,             "pablo_blk_ScanToFirst");
    22         s2k2CPPCode.put(S2KBuiltin.FLOW_SCAN_THRU,                 "pablo_blk_ScanThru");
    23         s2k2CPPCode.put(S2KBuiltin.FLOW_SCAN_TO,                   "pablo_blk_ScanTo");
    24         s2k2CPPCode.put(S2KBuiltin.FLOW_ADVANCE_THEN_SCAN_THRU,    "pablo_blk_AdvanceThenScanThru");
    25         s2k2CPPCode.put(S2KBuiltin.FLOW_ADVANCE_THEN_SCAN_TO,      "pablo_blk_AdvanceThenScanTo");
    26         s2k2CPPCode.put(S2KBuiltin.FLOW_SPAN_UP_TO,                "pablo_blk_SpanUpTo");
    27         s2k2CPPCode.put(S2KBuiltin.FLOW_INCLUSIVE_SPAN,            "pablo_blk_InclusiveSpan");
    28         s2k2CPPCode.put(S2KBuiltin.FLOW_EXCLUSIVE_SPAN,            "pablo_blk_ExclusiveSpan");   
    29         s2k2CPPCode.put(S2KBuiltin.FLOW_ADVANCE_N,                 "pablo_blk_Advance_n_<%s>");
    30         s2k2CPPCode.put(S2KBuiltin.FLOW_MASK,                      "Mask");
    31         s2k2CPPCode.put(S2KBuiltin.FLOW_AT_EOF,                    "atEOF");
    32         s2k2CPPCode.put(S2KBuiltin.FLOW_IN_FILE,                   "inFile");
    33         s2k2CPPCode.put(S2KBuiltin.FLOW_ASSERT_ZERO,               "assert_0_error");   
    34         s2k2CPPCode.put(S2KBuiltin.NULL_BUILTIN,              "null_builtin_error");
     20        s2k2CPPCode.put(S2KBuiltins.FLOW_ADVANCE,                       "pablo_blk_Advance");
     21        s2k2CPPCode.put(S2KBuiltins.FLOW_SCAN_TO_FIRST,                 "pablo_blk_ScanToFirst");
     22        s2k2CPPCode.put(S2KBuiltins.FLOW_SCAN_THRU,                     "pablo_blk_ScanThru");
     23        s2k2CPPCode.put(S2KBuiltins.FLOW_SCAN_TO,                       "pablo_blk_ScanTo");
     24        s2k2CPPCode.put(S2KBuiltins.FLOW_ADVANCE_THEN_SCAN_THRU,        "pablo_blk_AdvanceThenScanThru");
     25        s2k2CPPCode.put(S2KBuiltins.FLOW_ADVANCE_THEN_SCAN_TO,          "pablo_blk_AdvanceThenScanTo");
     26        s2k2CPPCode.put(S2KBuiltins.FLOW_SPAN_UP_TO,                    "pablo_blk_SpanUpTo");
     27        s2k2CPPCode.put(S2KBuiltins.FLOW_INCLUSIVE_SPAN,                "pablo_blk_InclusiveSpan");
     28        s2k2CPPCode.put(S2KBuiltins.FLOW_EXCLUSIVE_SPAN,                "pablo_blk_ExclusiveSpan");   
     29        s2k2CPPCode.put(S2KBuiltins.FLOW_ADVANCE_N,                     "pablo_blk_Advance_n_<%s>");
     30        s2k2CPPCode.put(S2KBuiltins.FLOW_MASK,                          "Mask");
     31        s2k2CPPCode.put(S2KBuiltins.FLOW_AT_EOF,                        "atEOF");
     32        s2k2CPPCode.put(S2KBuiltins.FLOW_IN_FILE,                       "inFile");
     33        s2k2CPPCode.put(S2KBuiltins.FLOW_ASSERT_ZERO,                   "assert_0_error");     
     34        s2k2CPPCode.put(S2KBuiltins.NULL_BUILTIN,                       "null_builtin_error");
    3535               
    36         for(S2KBuiltin builtin : S2KBuiltin.values()) {
     36        for(S2KBuiltins builtin : S2KBuiltins.values()) {
    3737                if(!s2k2CPPCode.containsKey(builtin)) {
    3838                                throw new RuntimeException("S2K builtin to CPP mapping not unimplemented in :" + S2KBuiltin2CPP.class.getSimpleName());
     
    4141    }
    4242   
    43         public String getName(S2KBuiltin builtin) {                     
     43        public String getName(S2KBuiltins builtin) {                   
    4444                return s2k2CPPCode.get(builtin);
    4545        }
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/S2KBuiltinEncoder.java

    r3812 r3816  
    22
    33public abstract class S2KBuiltinEncoder {
    4         public abstract String getName(S2KBuiltin builtin);
     4        public abstract String getName(S2KBuiltins builtin);
    55}
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/S2KBuiltinTranslator.java

    r3811 r3816  
    1414import toolchain.b2k.ast.Mutators;
    1515
    16 import toolchain.s2k.lang.S2KBuiltin;
     16import toolchain.s2k.lang.S2KBuiltins;
    1717import toolchain.s2k.transformer.visitors.S2K2B2K.Context;
    1818
     
    2323   
    2424        CARRY_TRANSLATION {     
    25                 public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     25                public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    2626           
    2727                    Locator locator = Generators.makeToken(snode.getToken());
     
    3636
    3737        ADVANCEN_TRANSLATION {
    38                 public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     38                public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    3939                    Locator locator = Generators.makeTextLocation(snode.getLocation());
    4040                       
     
    5252       
    5353        SCANTO_FIRST_TRANSLATION {
    54         public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     54        public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    5555            Locator locator = Generators.makeToken(snode.getToken());           
    5656           
     
    5959            }
    6060           
    61             return CARRY_TRANSLATION.translate(S2KBuiltin.FLOW_SCAN_TO_FIRST, snode, context, args);
     61            return CARRY_TRANSLATION.translate(S2KBuiltins.FLOW_SCAN_TO_FIRST, snode, context, args);
    6262        }
    6363        },
    6464       
    6565        SCANTO_TRANSLATION {
    66         public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     66        public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    6767            Locator locator = Generators.makeToken(snode.getToken());           
    6868           
    6969            args.set(1, translateScanToArgs(locator, context, args.get(1)));
    7070           
    71             return CARRY_TRANSLATION.translate(S2KBuiltin.FLOW_SCAN_THRU, snode, context, args);
     71            return CARRY_TRANSLATION.translate(S2KBuiltins.FLOW_SCAN_THRU, snode, context, args);
    7272        }
    7373    },
    7474
    7575    ADVANCE_THEN_SCANTO_TRANSLATION {
    76         public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     76        public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    7777            Locator locator = Generators.makeToken(snode.getToken());
    7878           
    7979            args.set(1, translateScanToArgs(locator, context, args.get(1)));   
    8080           
    81             return CARRY_TRANSLATION.translate(S2KBuiltin.FLOW_ADVANCE_THEN_SCAN_THRU, snode, context, args);
     81            return CARRY_TRANSLATION.translate(S2KBuiltins.FLOW_ADVANCE_THEN_SCAN_THRU, snode, context, args);
    8282        }
    8383
     
    8585   
    8686    ASSERT_ZERO_TRANSLATION {
    87         public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     87        public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    8888           
    8989            Locator locator = Generators.makeToken(snode.getToken());
     
    9292            ASTNode errorMsg                        = args.get(1);
    9393           
    94             String assert0CallName                  = context.getBuiltinEncoder().getName(S2KBuiltin.FLOW_ASSERT_ZERO);
     94            String assert0CallName                  = context.getBuiltinEncoder().getName(S2KBuiltins.FLOW_ASSERT_ZERO);
    9595
    9696            ASTNode assert0Call                     = Generators.makeFuncCallNode(locator, assert0CallName, errorStream, errorMsg);
     
    106106   
    107107    ATEOF_TRANSLATION {
    108         public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     108        public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    109109            Locator locator = Generators.makeToken(snode.getToken());
    110110           
     
    123123    INFILE_TRANSLATION {
    124124               
    125         public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     125        public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    126126            Locator locator = Generators.makeToken(snode.getToken());
    127127           
     
    135135
    136136    MASK_TRANSLATION {
    137         public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
     137        public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode snode, Context context, List<ASTNode> args) {
    138138           
    139139            Locator locator = Generators.makeToken(snode.getToken());
     
    146146
    147147    // Interface
    148     public ASTNode translate(S2KBuiltin builtin, s2k.ast.FuncCallNode node, Context context, List<ASTNode> args) {
     148    public ASTNode translate(S2KBuiltins builtin, s2k.ast.FuncCallNode node, Context context, List<ASTNode> args) {
    149149        assert false : "'pablo_blk_' S2KBuiltin translate not implemented for S2KBuitin: " + this.name();
    150150        return null;
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/S2KBuiltinTypeBuilder.java

    r3811 r3816  
    3737                SymbolTable symbolTable = new SymbolTable();
    3838               
    39                 for(S2KBuiltin builtin: S2KBuiltin.values()) {
     39                for(S2KBuiltins builtin: S2KBuiltins.values()) {
    4040                        installBuiltinBinding(builtin, symbolTable);
    4141                }
     
    4444        }
    4545
    46         private void installBuiltinBinding(S2KBuiltin builtin, SymbolTable symbolTable) {
     46        private void installBuiltinBinding(S2KBuiltins builtin, SymbolTable symbolTable) {
    4747                Binding binding = makeBinding(builtin);
    4848                symbolTable.add(binding);
    4949        }
    5050
    51         private Binding makeBinding(S2KBuiltin builtin) {
     51        private Binding makeBinding(S2KBuiltins builtin) {
    5252                String name = builtin.name();
    5353                Type type = FunctionType.make(builtin.getSignature());
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/S2KBuiltinUtil.java

    r3812 r3816  
    33import java.util.List;
    44
    5 
    65import s2k.ast.*;
    7 import toolchain.b2k.lang.idisa.IDISABuiltin;
    86import toolchain.s2k.ast.Accessors;
    97
     
    119       
    1210    public static boolean isAtEOF(ASTNode node) {
    13         return isBuiltInCall(node, S2KBuiltin.FLOW_AT_EOF);
     11        return isBuiltInCall(node, S2KBuiltins.FLOW_AT_EOF);
    1412    }
    1513    public static boolean isInFile(ASTNode node) {
    16         return isBuiltInCall(node, S2KBuiltin.FLOW_IN_FILE);
     14        return isBuiltInCall(node, S2KBuiltins.FLOW_IN_FILE);
    1715    }
    1816    public static boolean isAssertZero(ASTNode node) {
    19         return isBuiltInCall(node, S2KBuiltin.FLOW_ASSERT_ZERO);
     17        return isBuiltInCall(node, S2KBuiltins.FLOW_ASSERT_ZERO);
    2018    }
    2119    public static boolean isMask(ASTNode node) {
    22         return isBuiltInCall(node, S2KBuiltin.FLOW_MASK);
     20        return isBuiltInCall(node, S2KBuiltins.FLOW_MASK);
    2321    } 
    2422    public static boolean isAdvance1(ASTNode node) {
    25         return isBuiltInCall(node, S2KBuiltin.FLOW_ADVANCE);   
     23        return isBuiltInCall(node, S2KBuiltins.FLOW_ADVANCE);   
    2624    }   
    2725    public static boolean isAdvanceN(ASTNode node) {
    28         return isBuiltInCall(node, S2KBuiltin.FLOW_ADVANCE_N);   
     26        return isBuiltInCall(node, S2KBuiltins.FLOW_ADVANCE_N);   
    2927    }
    3028    public static boolean isAdvance(ASTNode node) {             // Advance(X) || Advance(X,n)
     
    3432    public static boolean isCarryNone(ASTNode node) {
    3533        if(isBuiltInCall(node)) {
    36             S2KBuiltin builtin = builtin(node);
     34            S2KBuiltins builtin = builtin(node);
    3735            return builtin.isCarryNone();
    3836        }
     
    4240    public static boolean isCarry1(ASTNode node) {
    4341        if(isBuiltInCall(node)) {
    44                 S2KBuiltin builtin = builtin(node);
     42                S2KBuiltins builtin = builtin(node);
    4543                return builtin.isCarry1();
    4644        }
     
    4947    public static boolean isCarryN(ASTNode node) {
    5048        if(isBuiltInCall(node)) {
    51                 S2KBuiltin builtin = builtin(node);
     49                S2KBuiltins builtin = builtin(node);
    5250                return builtin.isCarryN();
    5351        }
     
    7068        // guard invocations with isBuiltInCall
    7169        ///////////////////////////////////////////////////////////////////////////////////
    72         public static S2KBuiltin builtin(ASTNode node) {
     70        public static S2KBuiltins builtin(ASTNode node) {
    7371                assert isBuiltInCall(node) : "Unknown builtin: " + Accessors.name(node);
    7472                CompoundIdentifierNode compound = (CompoundIdentifierNode)Accessors.nameNode((FuncCallNode)node);
    7573                String fullyQualifiedName = Accessors.name(compound);
    76                 S2KBuiltin builtin = S2KBuiltin.forName(fullyQualifiedName);
     74                S2KBuiltins builtin = S2KBuiltins.forName(fullyQualifiedName);
    7775                return builtin;
    7876        }
     
    8179        // isBuiltinCall(node, builtin) - is this node an invocation of the given builtin?
    8280        ///////////////////////////////////////////////////////////////////////////////////
    83         public static boolean isBuiltInCall(ASTNode node, S2KBuiltin builtin) {
     81        public static boolean isBuiltInCall(ASTNode node, S2KBuiltins builtin) {
    8482                if(isBuiltInCall(node)) {
    8583                        return builtin(node) == builtin;
     
    104102                        CompoundIdentifierNode compound = (CompoundIdentifierNode)nameNode;
    105103                        String builtinName = Accessors.name(compound);
    106                         S2KBuiltin builtin = S2KBuiltin.forName(builtinName);
     104                        S2KBuiltins builtin = S2KBuiltins.forName(builtinName);
    107105
    108                         if (builtin != S2KBuiltin.NULL_BUILTIN) {
     106                        if (builtin != S2KBuiltins.NULL_BUILTIN) {
    109107                                return true;
    110108                        }                       
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/type/StreamType.java

    r3711 r3816  
    1010        static private Map<Integer, StreamType> forInteger = new HashMap<Integer, StreamType>();
    1111        static {
    12                 for(int powerOfTwo = 1; powerOfTwo <= 64; powerOfTwo = powerOfTwo*2) {
     12                for(int powerOfTwo = 1; powerOfTwo <= MAX_BIT_FIELD_SIZE; powerOfTwo = powerOfTwo*2) {
    1313                        forInteger.put(powerOfTwo, new StreamType(powerOfTwo));
    14                 }
     14                } // KH: ? 64 -> BITBLOCK_SIZE
    1515        }
    1616       
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/type/Type.java

    r3711 r3816  
    2828         */
    2929        public Type getConcreteType();
     30       
     31        public static final int MAX_BIT_FIELD_SIZE = 128; // TODO - KH: hoist to application level
    3032}
    3133
Note: See TracChangeset for help on using the changeset viewer.