Changeset 4106


Ignore:
Timestamp:
Aug 30, 2014, 10:46:36 PM (4 years ago)
Author:
ksherdy
Message:

Refactored support for sk s2k functions.

Location:
proto/s2k/trunk/framework/src/toolchain/s2k/lang/paramBuiltin
Files:
1 added
1 deleted
2 edited

Legend:

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

    r4021 r4106  
    77
    88package toolchain.s2k.lang.paramBuiltin;
    9 
    10 import toolchain.s2k.lang.builtin.S2KBuiltin;
    119
    1210public interface S2KParamBuiltin {
     
    2119        /** Returns the builtin with any builtin variables filled in with their values.
    2220         */
    23         public S2KBuiltin getConcreteBuiltin();
     21        public S2KParamBuiltin getConcreteBuiltin();
    2422               
    2523}
  • proto/s2k/trunk/framework/src/toolchain/s2k/lang/paramBuiltin/S2KParamBuiltins.java

    r4021 r4106  
    11package toolchain.s2k.lang.paramBuiltin;
    22
    3 import toolchain.s2k.lang.builtin.S2KBuiltin;
     3//import static toolchain.s2k.lang.signatures.SignatureShorthand.sig_V_V;
     4
     5import java.util.HashMap;
     6import java.util.Map;
     7// import static toolchain.s2k.lang.signatures.SignatureShorthand.sig_S_S;
     8
     9import toolchain.s2k.lang.paramBuiltin.S2KParamBuiltin;
     10
     11public enum S2KParamBuiltins implements S2KParamBuiltin {
     12
     13    HSTRM_PACKH(               "packh"), //,    sig_S_S()  );
     14    HSTRM_PACKL(               "packl"), //,    sig_S_S()  );   
     15    NULL_BUILTIN(              "NULL"); //,    sig_V_V()  );
     16   
     17    private final String name;
     18    //private final FunctionSignature signature;
     19
     20    private S2KParamBuiltins(String name) { //, FunctionSignature signature) {
     21        this.name = name;
     22        // this.signature = signature;
     23    }
     24
     25    /////////////////////////////////////////////////////////////////
     26    // forName(String)  mechanism
     27    /////////////////////////////////////////////////////////////////
     28    static private Map<String, S2KParamBuiltins> builtinForName = new HashMap<String, S2KParamBuiltins>();
     29    static {
     30        for(S2KParamBuiltins builtin: values()) {
     31            builtinForName.put(builtin.fullyQualifiedName(), builtin);
     32        }
     33    }
     34
     35    static public boolean isS2KParamBuiltins(String fullyQualifiedName) {
     36        return forName(fullyQualifiedName) != NULL_BUILTIN;
     37    }
     38   
     39    static public S2KParamBuiltins forName(String fullyQualifiedName) {
     40        if(builtinForName.containsKey(fullyQualifiedName)) {
     41            return builtinForName.get(fullyQualifiedName);
     42        }
     43        return NULL_BUILTIN;
     44    }
     45   
     46    /////////////////////////////////////////////////////////////////
     47    // queries
     48    /////////////////////////////////////////////////////////////////
     49    public String fullyQualifiedName () { return packageName() + "." + this.baseName() ;}
     50    public String packageName() { return  this.name().toLowerCase().split("_")[0]; }
     51    public String baseName() { return this.name; }
     52//    public FunctionSignature getSignature() { return signature; }
    453
    554
    6 
    7 public enum S2KParamBuiltins implements S2KParamBuiltin {
    8         ;
    9 
     55   
    1056        @Override
    1157        public String infoString() {
     
    1561
    1662        @Override
    17         public S2KBuiltin getConcreteBuiltin() {
     63        public S2KParamBuiltin getConcreteBuiltin() {
    1864                // TODO Auto-generated method stub
    1965                return null;
    2066        }
    21        
    22 
    23 
    24 
    25 
    2667
    2768}
Note: See TracChangeset for help on using the changeset viewer.