Changeset 3810


Ignore:
Timestamp:
Apr 11, 2014, 1:56:47 AM (4 years ago)
Author:
ksherdy
Message:

Modified code generator for IDISA support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/s2k/trunk/framework/src/toolchain/b2k/codeGenerator/visitors/CodeGenerator.java

    r3799 r3810  
    486486        }       
    487487
    488         public CodeStore visitLeave(IdisaFuncCallNode node, List<CodeStore> childResults) {
     488        public CodeStore visitLeave(IdisaFuncCallNode node, List<CodeStore> childResults) {  
    489489                CodeStore code = new CodeStore();
    490490               
     
    494494                String fieldWidth                               = childResults.get(1).getResultVarName();
    495495                String arguments                                = childResults.get(2).getResultVarName();
    496                
    497                 //
    498                 IDISABuiltin idisaBuiltin = IDISABuiltin.fromString(idisaFullyQualifiedName);
    499                 assert idisaBuiltin != null :
    500                         "Unknown IDISA operation name: " + idisaPackageName + "::" + idisaOperationName;
    501                 assert idisaBuiltin.hasSignature(Integer.valueOf(fieldWidth)) :
    502                         "Unknown IDISA operation at field width: " + idisaPackageName + "::" + idisaOperationName + "<" + fieldWidth + ">" ;
    503                
    504                 // AbstractIDISABuiltinGenerator
     496                int argCount                    = Accessors.argCount(node);
     497                               
     498                IDISABuiltin idisaBuiltin = IDISABuiltin.forName(idisaFullyQualifiedName);
     499                assert idisaBuiltin != IDISABuiltin.NULL_BUILTIN :
     500                        "Unknown IDISA operation: " + idisaFullyQualifiedName;
     501               
     502                assert (idisaBuiltin.hasSignature(Integer.valueOf(fieldWidth), argCount)) :
     503                        "Unknown IDISA operation: " + idisaFullyQualifiedName + "<" + fieldWidth + ">";
     504               
    505505                AbstractIDISABuiltinGenerator idisaBuiltinsGenerator
    506                         = idisaBuiltin.getSignature(Integer.valueOf(fieldWidth)).getIDISABuiltinsGenerator();           
     506                        = (AbstractIDISABuiltinGenerator) idisaBuiltin.getSignature(Integer.valueOf(fieldWidth), argCount).getVariant();               
    507507               
    508508                String idisaFuncCallString
    509509                    = idisaBuiltinsGenerator.makeIDISAFuncCall(idisaBuiltins2Lang, idisaPackageName, idisaOperationName, fieldWidth, arguments);               
    510510               
    511                 code.setResultVarName(idisaFuncCallString);             // Function invocation as an expression
    512                 code.addFormattedLine("%s;", idisaFuncCallString);      // Function invocation as a statement
     511                code.setResultVarName(idisaFuncCallString);             // invocation as an expression 
     512                code.addFormattedLine("%s;", idisaFuncCallString);      // invocation as a statement
    513513               
    514514                return code;
     
    602602        }       
    603603
    604         public CodeStore visitLeave(VoidTypeNode node, List<CodeStore> childResults) {
    605                 CodeStore code = new CodeStore();
    606                 code.setResultVarName(Accessors.voidLexeme(node));
     604//      public CodeStore visitLeave(VoidTypeNode node, List<CodeStore> childResults) {
     605//              CodeStore code = new CodeStore();
     606//              code.setResultVarName(Accessors.voidLexeme(node));
     607//              return code;
     608//      }               
     609
     610        public CodeStore visitLeave(IntTypeNode node, List<CodeStore> childResults) {
     611                CodeStore code = new CodeStore();
     612                code.setResultVarName(Accessors.intLexeme(node));
    607613                return code;
    608614        }               
     
    613619                return code;
    614620        }               
    615                
     621       
    616622        public CodeStore visitLeave(CompoundIdentifierNode node, List<CodeStore> childResults) {
    617623                CodeStore code = new CodeStore();
     
    627633        }
    628634
     635        //////////////////////////////////////////////////////////////
     636        // kernel function helpers     
     637       
    629638        public CodeStore makeKernelDoBlockCallStmt(AddKernelStmtNode addKernelStmt) {
    630639                CodeStore code = new CodeStore();
Note: See TracChangeset for help on using the changeset viewer.