Changeset 13653


Ignore:
Timestamp:
Oct 3, 2019 10:55:33 AM (2 months ago)
Author:
jwedin
Message:

Refactored the code generation for delay expressions. #5852

Location:
branches/dev-1247-jw/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-1247-jw/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenExpressions.jrag

    r13431 r13653  
    13521352        p.printVarDecls(myMaxDelayExp(), str, indent);
    13531353    }
    1354    
    1355     /**
    1356      * Generate the initialization of delay blocks.
    1357      */
    1358     public void FDelayExp.genInit_C(CodePrinter p, CodeStream str, String indent) {
    1359         FExp maxDelayExp = myMaxDelayExp();
    1360         boolean fixed = isTimeEventGenerating();
    1361         p.printPreSteps(getFExp(), str, indent);
     1354
     1355    /**
     1356     * Generates the first part of a delay_init call
     1357     */
     1358    private void FDelayExp.genInit_C_Header(CodePrinter p, CodeStream str, String indent, FExp maxDelayExp, boolean fixed,
     1359            int delayIndex) {
     1360        p.printPreSteps(getFExp(), str, indent);
    13621361        p.printPreSteps(maxDelayExp, str, indent);
    1363        
    1364         str.format("%sjmi_delay_init(jmi, %d, ", indent, myDelayIndex());
     1362        str.format("%sjmi_delay_init(jmi, %d, ", indent, delayIndex);
    13651363        str.print(boolValue_C(fixed)); // jmi_boolean fixed
    13661364        str.print(", ");
     
    13681366        str.print(", ");
    13691367        p.print(fixed ? getDelay() : maxDelayExp, str, indent); // jmi_real_t max_delay
    1370         str.print(", ");
    1371         p.print(getFExp(), str, indent); // jmi_real_t y0
    1372         str.println(");");
    1373        
     1368        str.print(", ");
     1369    }
     1370   
     1371    /**
     1372     * Generate the initialization of delay blocks.
     1373     */
     1374    public void FDelayExp.genInit_C(CodePrinter p, CodeStream str, String indent) {
     1375        FExp maxDelayExp = myMaxDelayExp();
     1376        boolean fixed = isTimeEventGenerating();
     1377
     1378        genInit_C_Header(p, str, indent, maxDelayExp, fixed, myDelayIndex());
     1379        p.print(getFExp(), str, indent); // jmi_real_t y0
     1380        str.println(");");
     1381
    13741382        p.printPostSteps(getFExp(), str, indent);
    13751383        p.printPostSteps(maxDelayExp, str, indent);
  • branches/dev-1247-jw/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CGenerator.jrag

    r12423 r13653  
    2121
    2222import java.io.*;
     23
     24aspect CGenerator {
    2325
    2426public class CGenerator extends GenericGenerator {
     
    12461248       
    12471249        public void generate(CodeStream genPrinter) {
    1248             genPrinter.print(fclass.myDelayExps().size());
     1250            genPrinter.print(fclass.numberOfDelaysInCCode());
    12491251        }
    12501252    }
     
    15781580    }
    15791581}
     1582
     1583    syn int FClass.numberOfDelaysInCCode() = myDelayExps().size(); // Hook to facilitate extensions
     1584}
Note: See TracChangeset for help on using the changeset viewer.