stage4/generate_cc/generate_cc.cc
author lbessard
Wed, 16 May 2007 17:53:37 +0200
changeset 28 5b170c9ce134
parent 27 667721cf52c5
child 29 3ba8ef691003
permissions -rwxr-xr-x
Multi-file configuration and resource generation finished
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     1
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     2
 * (c) 2003 Mario de Sousa
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     3
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     4
 * Offered to the public under the terms of the GNU General Public License
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     5
 * as published by the Free Software Foundation; either version 2 of the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     6
 * License, or (at your option) any later version.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     7
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     8
 * This program is distributed in the hope that it will be useful, but
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
     9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    11
 * Public License for more details.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    12
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    13
 * This code is made available on the understanding that it will not be
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    14
 * used in safety-critical situations without a full and competent review.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    15
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    16
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    17
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    18
 * An IEC 61131-3 IL and ST compiler.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    19
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    20
 * Based on the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    21
 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    22
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    23
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    24
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    25
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    26
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    27
 * This is one of the versions available for the 4th stage.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    28
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    29
 * This 4th stage generates a c++ source program equivalent
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    30
 * to the IL and ST code.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    31
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    32
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    33
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    34
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    35
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    36
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    37
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    38
// #include <stdio.h>  /* required for NULL */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    39
#include <string>
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    40
#include <iostream>
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
    41
#include <sstream>
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
    42
#include <typeinfo>
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    43
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    44
#include "../../util/symtable.hh"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    45
#include "../../util/dsymtable.hh"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    46
#include "../../absyntax/visitor.hh"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    47
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    48
#include "../stage4.hh"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    49
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    50
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    51
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    52
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    53
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    54
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    55
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    56
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    57
//#define DEBUG
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    58
#ifdef DEBUG
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    59
#define TRACE(classname) printf("\n____%s____\n",classname);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    60
#else
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    61
#define TRACE(classname)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    62
#endif
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    63
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    64
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    65
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    66
#define ERROR error_exit(__FILE__,__LINE__)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    67
/* function defined in main.cc */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    68
extern void error_exit(const char *file_name, int line_no);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    69
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    70
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    71
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    72
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    73
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    74
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    75
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    76
/* A symbol table with all globally declared functions... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    77
function_declaration_c null_symbol1(NULL,NULL,NULL,NULL);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    78
dsymtable_c<function_declaration_c *, &null_symbol1> function_symtable;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    79
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    80
/* A symbol table with all globally declared functions block types... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    81
function_block_declaration_c null_symbol2(NULL,NULL,NULL,NULL);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    82
symtable_c<function_block_declaration_c *, &null_symbol2> function_block_type_symtable;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    83
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    84
/* A symbol table with all globally declared program types... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    85
program_declaration_c null_symbol3(NULL,NULL,NULL,NULL);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    86
symtable_c<program_declaration_c *, &null_symbol3> program_type_symtable;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    87
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    88
/* A symbol table with all user declared type definitions... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    89
/* Note that function block types and program types have their
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    90
 * own symbol tables, so do not get placed in this symbol table!
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    91
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    92
symbol_c null_symbol4;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    93
symtable_c<symbol_c *, &null_symbol4> type_symtable;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    94
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    95
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    96
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    97
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    98
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
    99
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   100
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   101
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   102
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   103
/* returns 0 if the names are equal!! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   104
/* NOTE: it must ignore case!! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   105
static int compare_identifiers(symbol_c *ident1, symbol_c *ident2) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   106
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   107
  token_c *name1 = dynamic_cast<token_c *>(ident1);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   108
  token_c *name2 = dynamic_cast<token_c *>(ident2);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   109
  
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   110
  if ((name1 == NULL) || (name2 == NULL))
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   111
    /* invalid identifiers... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   112
    return -1;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   113
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   114
  if (strcasecmp(name1->value, name2->value) == 0)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   115
    return 0;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   116
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   117
  /* identifiers do not match! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   118
  return 1;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   119
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   120
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   121
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   122
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   123
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   124
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   125
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   126
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   127
/* Unlike Programs and Configurations which get mapped onto C++ classes,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   128
 * Function Blocks are mapped onto a C structure containing the variables, and
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   129
 * a C function containing the code in the FB's body. This is to allow direct allocation
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   130
 * of a FB variable (which is really an instance of the C data structure) to
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   131
 * a member of a union variable (note that classes with constructors cannot
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   132
 * be mebers of a union), which is done in IL when loading a FB onto IL's
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   133
 * default variable.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   134
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   135
 * So as not to clash the names of the C data structure and the C function,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   136
 * the C structure is given a name identical to that of the FB name, whereas
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   137
 * the name of the function is the FB name with a constant string appended.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   138
 * The value of that constant string which is appended is defined in the following
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   139
 * constant.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   140
 * In order not to clash with any variable in the IL and ST source codem the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   141
 * following constant should contain a double underscore, which is not allowed
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   142
 * in IL and ST.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   143
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   144
 * e.g.:  FUNTION_BLOCK TEST
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   145
 * is mapped onto a TEST data structure, and a TEST_body__ function.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   146
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   147
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   148
#define FB_FUNCTION_SUFFIX "_body__"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   149
23
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   150
/* Idem as body, but for initializer FB function */
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   151
#define FB_INIT_SUFFIX "_init__"
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   152
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   153
/* Idem as body, but for run CONFIG and RESOURCE function */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   154
#define FB_RUN_SUFFIX "_run__"
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   155
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   156
/* The FB body function is passed as the only parameter a pointer to the FB data
18
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   157
 * structure instance. The name of this parameter is given by the following constant.
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   158
 * In order not to clash with any variable in the IL and ST source codem the
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   159
 * following constant should contain a double underscore, which is not allowed
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   160
 * in IL and ST.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   161
 *
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   162
 * e.g.: the body of FUNTION_BLOCK TEST
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   163
 * is mapped onto the C function
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   164
 *  TEST_body__(TEST *data__)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   165
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   166
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   167
#define FB_FUNCTION_PARAM "data__"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   168
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   169
18
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   170
#define SFC_STEP_ACTION_PREFIX "__SFC_"
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   171
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   172
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   173
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   174
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   175
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   176
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   177
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   178
#include "spec_init_separator.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   179
#include "function_param_iterator.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   180
#include "function_call_iterator.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   181
#include "function_call_param_iterator.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   182
#include "type_initial_value.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   183
#include "search_fb_instance_decl.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   184
#include "search_base_type.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   185
#include "search_var_instance_decl.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   186
#include "decompose_var_instance_name.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   187
#include "search_varfb_instance_type.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   188
#include "search_constant_type.cc"
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   189
#include "search_expression_type.cc"
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   190
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   191
#include "generate_cc_base.cc"
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   192
#include "generate_cc_sfcdecl.cc"
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   193
#include "generate_cc_typedecl.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   194
#include "generate_cc_vardecl.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   195
#include "generate_cc_configbody.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   196
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   197
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   198
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   199
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   200
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   201
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   202
/* Generate a name for a temporary variable.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   203
 * Each new name generated is appended a different number,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   204
 * starting off from 0.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   205
 * After calling reset(), the names will start off again from 0.
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   206
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   207
#define VAR_LEADER "__"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   208
#define TEMP_VAR VAR_LEADER "TMP_"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   209
#define SOURCE_VAR VAR_LEADER "SRC_"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   210
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   211
#include "generate_cc_tempvardecl.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   212
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   213
#include "generate_cc_st.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   214
#include "generate_cc_il.cc"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   215
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   216
#include "generate_cc.hh"
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   217
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   218
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   219
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   220
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   221
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   222
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   223
#define MILLISECOND 1000000
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   224
#define SECOND 1000 * MILLISECOND
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   225
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   226
/* A helper class that knows how to generate code for both the IL and ST languages... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   227
class calculate_time_c: public iterator_visitor_c {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   228
  private:
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   229
    unsigned long time;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   230
    float current_value;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   231
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   232
  public:
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   233
    calculate_time_c(void){time = 0;};
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   234
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   235
    unsigned long get_time(void) {return time;};
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   236
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   237
    void *get_integer_value(token_c *token) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   238
      std::string str = "";
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   239
      for (unsigned int i = 0; i < strlen(token->value); i++)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   240
        if (token->value[i] != '_')
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   241
          str += token->value[i];
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   242
      current_value = atof(str.c_str());
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   243
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   244
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   245
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   246
    void *get_float_value(token_c *token) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   247
      current_value = atof(token->value);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   248
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   249
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   250
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   251
/******************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   252
/* B 1.2.1 - Numeric Literals */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   253
/******************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   254
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   255
    void *visit(integer_c *symbol) {return get_integer_value(symbol);}
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   256
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   257
/************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   258
/* B 1.2.3.1 - Duration */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   259
/************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   260
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   261
    /* SYM_REF2(duration_c, neg, interval) */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   262
    void *visit(duration_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   263
      if (symbol->neg != NULL)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   264
        ERROR;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   265
      symbol->interval->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   266
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   267
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   268
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   269
    /* SYM_TOKEN(fixed_point_c) */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   270
    void *visit(fixed_point_c *symbol) {return get_float_value(symbol);}
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   271
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   272
    /* SYM_REF2(days_c, days, hours) */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   273
    void *visit(days_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   274
      if (symbol->hours)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   275
        symbol->hours->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   276
      symbol->days->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   277
      time += (unsigned long)(current_value * 24 * 3600 * SECOND);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   278
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   279
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   280
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   281
    /* SYM_REF2(hours_c, hours, minutes) */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   282
    void *visit(hours_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   283
      if (symbol->minutes)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   284
        symbol->minutes->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   285
      symbol->hours->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   286
      time += (unsigned long)(current_value * 3600 * SECOND);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   287
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   288
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   289
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   290
    /* SYM_REF2(minutes_c, minutes, seconds) */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   291
    void *visit(minutes_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   292
      if (symbol->seconds)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   293
        symbol->seconds->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   294
      symbol->minutes->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   295
      time += (unsigned long)(current_value * 60 * SECOND);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   296
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   297
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   298
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   299
    /* SYM_REF2(seconds_c, seconds, milliseconds) */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   300
    void *visit(seconds_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   301
      if (symbol->milliseconds)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   302
        symbol->milliseconds->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   303
      symbol->seconds->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   304
      time += (unsigned long)(current_value * SECOND);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   305
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   306
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   307
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   308
    /* SYM_REF2(milliseconds_c, milliseconds, unused) */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   309
    void *visit(milliseconds_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   310
      symbol->milliseconds->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   311
      time += (unsigned long)(current_value * MILLISECOND);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   312
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   313
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   314
};
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   315
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   316
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   317
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   318
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   319
/***********************************************************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   320
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   321
class calculate_common_ticktime_c: public iterator_visitor_c {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   322
  private:
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   323
    unsigned long common_ticktime;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   324
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   325
  public:
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   326
    calculate_common_ticktime_c(void){common_ticktime = 0;}
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   327
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   328
    unsigned long euclide(unsigned long a, unsigned long b) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   329
      unsigned long c = a % b;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   330
      if (c == 0)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   331
        return b;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   332
      else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   333
        return euclide(b, c);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   334
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   335
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   336
    void update_ticktime(unsigned long time) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   337
      if (common_ticktime == 0)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   338
        common_ticktime = time;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   339
      else if (time > common_ticktime)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   340
        common_ticktime = euclide(time, common_ticktime);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   341
      else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   342
        common_ticktime = euclide(common_ticktime, time);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   343
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   344
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   345
    unsigned long get_ticktime(void) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   346
      return common_ticktime;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   347
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   348
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   349
/*  TASK task_name task_initialization */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   350
//SYM_REF2(task_configuration_c, task_name, task_initialization)  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   351
    void *visit(task_initialization_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   352
      calculate_time_c calculate_time;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   353
      unsigned long time = 0;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   354
      if (symbol->interval_data_source != NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   355
        symbol->interval_data_source->accept(calculate_time);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   356
        time = calculate_time.get_time();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   357
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   358
      if (time > 0)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   359
        update_ticktime(time);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   360
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   361
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   362
};    
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   363
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   364
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   365
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   366
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   367
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   368
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   369
/* A helper class that knows how to generate code for both the IL and ST languages... */
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   370
class generate_cc_SFC_IL_ST_c: public null_visitor_c {
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   371
  private:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   372
    stage4out_c *s4o_ptr;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   373
    symbol_c *scope;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   374
    const char *variable_prefix;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   375
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   376
  public:
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   377
    generate_cc_SFC_IL_ST_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL);
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   378
    /*********************************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   379
    /* B.1.6  Sequential function chart elements */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   380
    /*********************************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   381
    
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   382
    /*| sequential_function_chart sfc_network*/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   383
    void *visit(sequential_function_chart_c * symbol);
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   384
    
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   385
    /****************************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   386
    /* B.2 - Language IL (Instruction List) */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   387
    /****************************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   388
    
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   389
    /***********************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   390
    /* B 2.1 Instructions and Operands */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   391
    /***********************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   392
    /*| instruction_list il_instruction */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   393
    void *visit(instruction_list_c *symbol);
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   394
    
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   395
    /* Remainder implemented in generate_cc_il_c... */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   396
    
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   397
    /***************************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   398
    /* B.3 - Language ST (Structured Text) */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   399
    /***************************************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   400
    /***********************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   401
    /* B 3.1 - Expressions */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   402
    /***********************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   403
    /* Implemented in generate_cc_st_c */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   404
    
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   405
    /********************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   406
    /* B 3.2 Statements */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   407
    /********************/
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   408
    void *visit(statement_list_c *symbol);
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   409
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   410
/* Remainder implemented in generate_cc_st_c... */
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   411
};
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   412
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   413
#include "generate_cc_sfc.cc"
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   414
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   415
generate_cc_SFC_IL_ST_c::generate_cc_SFC_IL_ST_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix) {
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   416
  if (NULL == scope) ERROR;
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   417
  this->s4o_ptr = s4o_ptr;
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   418
  this->scope = scope;
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   419
  this->variable_prefix = variable_prefix;
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   420
}
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   421
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   422
void *generate_cc_SFC_IL_ST_c::visit(sequential_function_chart_c * symbol) {
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   423
  generate_cc_sfc_c generate_cc_sfc(s4o_ptr, scope, variable_prefix);
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   424
  generate_cc_sfc.generate(symbol);
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   425
  return NULL;
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   426
}
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   427
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   428
void *generate_cc_SFC_IL_ST_c::visit(instruction_list_c *symbol) {
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   429
  generate_cc_il_c generate_cc_il(s4o_ptr, scope, variable_prefix);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   430
  generate_cc_il.generate(symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   431
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   432
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   433
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   434
void *generate_cc_SFC_IL_ST_c::visit(statement_list_c *symbol) {
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   435
  generate_cc_st_c generate_cc_st(s4o_ptr, scope, variable_prefix);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   436
  generate_cc_st.generate(symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   437
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   438
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   439
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   440
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   441
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   442
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   443
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   444
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   445
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   446
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   447
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   448
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   449
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   450
class generate_cc_pous_c: public generate_cc_typedecl_c {
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   451
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   452
  public:
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   453
    generate_cc_pous_c(stage4out_c *s4o_ptr)
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   454
      : generate_cc_typedecl_c(s4o_ptr) {};
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   455
    virtual ~generate_cc_pous_c(void) {}
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   456
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   457
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   458
  public:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   459
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   460
/* B 0 - Programming Model */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   461
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   462
void *visit(library_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   463
  TRACE("library_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   464
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   465
  /* Insert the header... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   466
  s4o.print("/*******************************************/\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   467
  s4o.print("/*     FILE GENERATED BY iec2cc            */\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   468
  s4o.print("/* Editing this file is not recommended... */\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   469
  s4o.print("/*******************************************/\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   470
  s4o.print("\n\n\n\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   471
  s4o.print("#include \"plciec.h\"\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   472
  s4o.print("\n\n\n\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   473
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   474
  /* now do the actual code... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   475
  print_list(symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   476
  s4o.print("\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   477
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   478
  /* Finish off with the main() */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   479
  s4o.print("#include \"plciec.cc\"\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   480
  s4o.print("\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   481
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   482
  // function_symtable.print();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   483
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   484
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   485
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   486
/*************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   487
/* B.1 - Common elements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   488
/*************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   489
/*******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   490
/* B 1.1 - Letters, digits and identifiers */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   491
/*******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   492
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   493
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   494
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   495
/* B 1.2 - Constants */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   496
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   497
  /* originally empty... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   498
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   499
/******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   500
/* B 1.2.1 - Numeric Literals */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   501
/******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   502
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   503
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   504
/*******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   505
/* B.1.2.2   Character Strings */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   506
/*******************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   507
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   508
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   509
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   510
/* B 1.2.3 - Time Literals */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   511
/***************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   512
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   513
/* B 1.2.3.1 - Duration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   514
/************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   515
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   516
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   517
/************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   518
/* B 1.2.3.2 - Time of day and Date */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   519
/************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   520
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   521
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   522
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   523
/* B.1.3 - Data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   524
/**********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   525
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   526
/* B 1.3.1 - Elementary Data Types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   527
/***********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   528
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   529
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   530
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   531
/* B.1.3.2 - Generic data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   532
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   533
  /* originally empty... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   534
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   535
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   536
/* B 1.3.3 - Derived data types */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   537
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   538
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   539
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   540
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   541
/* B 1.4 - Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   542
/*********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   543
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   544
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   545
/********************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   546
/* B.1.4.1   Directly Represented Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   547
/********************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   548
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   549
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   550
/*************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   551
/* B.1.4.2   Multi-element Variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   552
/*************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   553
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   554
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   555
/******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   556
/* B 1.4.3 - Declaration & Initialisation */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   557
/******************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   558
  /* done in base class(es) */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   559
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   560
/**************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   561
/* B.1.5 - Program organization units */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   562
/**************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   563
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   564
/* B 1.5.1 - Functions */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   565
/***********************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   566
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   567
public:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   568
/*   FUNCTION derived_function_name ':' elementary_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   569
/* | FUNCTION derived_function_name ':' derived_type_name io_OR_function_var_declarations_list function_body END_FUNCTION */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   570
void *visit(function_declaration_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   571
  generate_cc_vardecl_c *vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   572
  TRACE("function_declaration_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   573
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   574
  /* start off by adding this declaration to the global
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   575
   * function declaration symbol table...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   576
   */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   577
  function_symtable.insert(symbol->derived_function_name, symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   578
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   579
  /* (A) Function declaration... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   580
  /* (A.1) Function return type */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   581
  s4o.print("// FUNCTION\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   582
  symbol->type_name->accept(*this); /* return type */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   583
  s4o.print(" ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   584
  /* (A.2) Function name */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   585
  symbol->derived_function_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   586
  s4o.print("(");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   587
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   588
  /* (A.3) Function parameters */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   589
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   590
  vardecl = new generate_cc_vardecl_c(&s4o,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   591
  				      generate_cc_vardecl_c::finterface_vf,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   592
  				      generate_cc_vardecl_c::input_vt |
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   593
				      generate_cc_vardecl_c::output_vt |
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   594
				      generate_cc_vardecl_c::inoutput_vt);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   595
  vardecl->print(symbol->var_declarations_list);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   596
  delete vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   597
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   598
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   599
  s4o.print(")\n" + s4o.indent_spaces + "{\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   600
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   601
  /* (B) Function local variable declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   602
    /* (B.1) Variables declared in ST source code */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   603
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   604
  vardecl = new generate_cc_vardecl_c(&s4o, generate_cc_vardecl_c::localinit_vf, generate_cc_vardecl_c::private_vt);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   605
  vardecl->print(symbol->var_declarations_list);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   606
  delete vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   607
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   608
    /* (B.2) Temporary variable for function's return value */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   609
  /* It will have the same name as the function itself! */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   610
  s4o.print(s4o.indent_spaces);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   611
  symbol->type_name->accept(*this); /* return type */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   612
  s4o.print(" ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   613
  symbol->derived_function_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   614
  s4o.print(" = ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   615
  {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   616
    /* get the default value of this variable's type */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   617
    symbol_c *default_value = (symbol_c *)symbol->type_name->accept(*type_initial_value_c::instance());
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   618
    if (default_value == NULL) ERROR;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   619
    default_value->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   620
  }
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   621
  s4o.print(";\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   622
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   623
  /* (C) Function body */
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   624
  generate_cc_SFC_IL_ST_c generate_cc_code(&s4o, symbol);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   625
  symbol->function_body->accept(generate_cc_code);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   626
  s4o.print(s4o.indent_spaces + "return ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   627
  symbol->derived_function_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   628
  s4o.print(";\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   629
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   630
  s4o.print(s4o.indent_spaces + "}\n\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   631
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   632
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   633
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   634
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   635
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   636
/* The remaining var_declarations_list_c, function_var_decls_c
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   637
 * and var2_init_decl_list_c are handled in the generate_cc_vardecl_c class
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   638
 */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   639
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   640
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   641
/*****************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   642
/* B 1.5.2 - Function Blocks */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   643
/*****************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   644
public:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   645
/*  FUNCTION_BLOCK derived_function_block_name io_OR_other_var_declarations function_block_body END_FUNCTION_BLOCK */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   646
//SYM_REF4(function_block_declaration_c, fblock_name, var_declarations, fblock_body, unused)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   647
void *visit(function_block_declaration_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   648
  generate_cc_vardecl_c *vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   649
  TRACE("function_block_declaration_c");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   650
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   651
  /* start off by adding this declaration to the global
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   652
   * function block declaration symbol table...
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   653
   */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   654
  function_block_type_symtable.insert(symbol->fblock_name, symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   655
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   656
  /* (A) Function Block data structure declaration... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   657
  /* (A.1) Data structure declaration */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   658
  s4o.print("// FUNCTION_BLOCK ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   659
  symbol->fblock_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   660
  s4o.print("\n// Data part\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   661
  s4o.print("typedef struct {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   662
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   663
  /* (A.2) Public variables: i.e. the function parameters... */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   664
  s4o.print(s4o.indent_spaces + "// FB Interface - IN, OUT, IN_OUT variables\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   665
  vardecl = new generate_cc_vardecl_c(&s4o,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   666
  				      generate_cc_vardecl_c::local_vf,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   667
  				      generate_cc_vardecl_c::input_vt |
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   668
  				      generate_cc_vardecl_c::output_vt |
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   669
  				      generate_cc_vardecl_c::inoutput_vt);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   670
  vardecl->print(symbol->var_declarations);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   671
  delete vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   672
  s4o.print("\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   673
  /* (A.3) Private internal variables */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   674
  s4o.print(s4o.indent_spaces + "// FB private variables - TEMP, private and located variables\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   675
  vardecl = new generate_cc_vardecl_c(&s4o,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   676
  				      generate_cc_vardecl_c::local_vf,
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   677
				        generate_cc_vardecl_c::temp_vt |
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   678
  				      generate_cc_vardecl_c::private_vt |
23
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   679
  				      generate_cc_vardecl_c::located_vt |
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   680
  				      generate_cc_vardecl_c::external_vt);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   681
  vardecl->print(symbol->var_declarations);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   682
  delete vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   683
  s4o.print("\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   684
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   685
  /* (A.4) Function Block data structure type name. */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   686
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   687
  s4o.print("} ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   688
  symbol->fblock_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   689
  s4o.print(";\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   690
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   691
23
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   692
  /* (B) Constructor */
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   693
  /* (B.1) Constructor name... */
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   694
  s4o.print(s4o.indent_spaces + "void ");
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   695
  symbol->fblock_name->accept(*this);
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   696
  s4o.print(FB_INIT_SUFFIX);
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   697
  s4o.print("(");
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   698
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   699
  /* first and only parameter is a pointer to the data */
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   700
  symbol->fblock_name->accept(*this);
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   701
  s4o.print(" *");
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   702
  s4o.print(FB_FUNCTION_PARAM);
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   703
  s4o.print(") {\n");
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   704
  s4o.indent_right();
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   705
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   706
  /* (B.2) Member initializations... */
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   707
  s4o.print(s4o.indent_spaces);
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   708
  vardecl = new generate_cc_vardecl_c(&s4o,
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   709
  				      generate_cc_vardecl_c::constructorinit_vf,
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   710
  				      generate_cc_vardecl_c::input_vt |
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   711
  				      generate_cc_vardecl_c::output_vt |
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   712
  				      generate_cc_vardecl_c::inoutput_vt |
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   713
  				      generate_cc_vardecl_c::private_vt |
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   714
				        generate_cc_vardecl_c::located_vt |
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   715
				        generate_cc_vardecl_c::external_vt);
23
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   716
  vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   717
  delete vardecl;
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   718
  s4o.indent_left();
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   719
  s4o.print("\n" + s4o.indent_spaces + "}\n\n");
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   720
d5b55ac4efe6 Adding init function on functionBlock
etisserant
parents: 18
diff changeset
   721
  
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   722
  /* (C) Function with FB body */
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   723
  /* (C.1) Function declaration */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   724
  s4o.print("// Code part\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   725
  /* function interface */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   726
  s4o.print("void ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   727
  symbol->fblock_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   728
  s4o.print(FB_FUNCTION_SUFFIX);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   729
  s4o.print("(");
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   730
  /* first and only parameter is a pointer to the data */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   731
  symbol->fblock_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   732
  s4o.print(" *");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   733
  s4o.print(FB_FUNCTION_PARAM);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   734
  s4o.print(") {\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   735
  s4o.indent_right();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   736
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   737
  /* (C.2) Initialize TEMP variables */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   738
  /* function body */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   739
  s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   740
  vardecl = new generate_cc_vardecl_c(&s4o,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   741
  				      generate_cc_vardecl_c::init_vf,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   742
				      generate_cc_vardecl_c::temp_vt);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   743
  vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   744
  delete vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   745
  s4o.print("\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   746
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   747
  /* (C.3) Function code */
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   748
  generate_cc_SFC_IL_ST_c generate_cc_code(&s4o, symbol, FB_FUNCTION_PARAM"->");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   749
  symbol->fblock_body->accept(generate_cc_code);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   750
  s4o.indent_left();
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   751
  s4o.print(s4o.indent_spaces + "} // ");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   752
  symbol->fblock_name->accept(*this);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   753
  s4o.print(FB_FUNCTION_SUFFIX);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   754
  s4o.print(s4o.indent_spaces + "() \n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   755
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   756
  s4o.indent_left();
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   757
  s4o.print("\n\n\n\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   758
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   759
  return NULL;
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   760
}
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   761
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   762
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   763
/* The remaining temp_var_decls_c, temp_var_decls_list_c
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   764
 * and non_retentive_var_decls_c are handled in the generate_cc_vardecl_c class
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   765
 */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   766
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   767
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   768
/**********************/
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   769
/* B 1.5.3 - Programs */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   770
/**********************/
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   771
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   772
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   773
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   774
public:
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   775
/*  PROGRAM program_type_name program_var_declarations_list function_block_body END_PROGRAM */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   776
//SYM_REF4(program_declaration_c, program_type_name, var_declarations, function_block_body, unused)
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   777
void *visit(program_declaration_c *symbol) {
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   778
  generate_cc_vardecl_c *vardecl;
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   779
  TRACE("program_declaration_c");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   780
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   781
  /* start off by adding this declaration to the global
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   782
   * program declaration symbol table...
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   783
   */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   784
  program_type_symtable.insert(symbol->program_type_name, symbol);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   785
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   786
  /* (A) Program data structure declaration... */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   787
  /* (A.1) Data structure declaration */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   788
  s4o.print("// PROGRAM ");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   789
  symbol->program_type_name->accept(*this);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   790
  s4o.print("\n// Data part\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   791
  s4o.print("typedef struct {\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   792
  s4o.indent_right();
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   793
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   794
  /* (A.2) Public variables: i.e. the program parameters... */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   795
  s4o.print(s4o.indent_spaces + "// PROGRAM Interface - IN, OUT, IN_OUT variables\n");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   796
  vardecl = new generate_cc_vardecl_c(&s4o,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   797
  				      generate_cc_vardecl_c::local_vf,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   798
  				      generate_cc_vardecl_c::input_vt |
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   799
  				      generate_cc_vardecl_c::output_vt |
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   800
  				      generate_cc_vardecl_c::inoutput_vt);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   801
  vardecl->print(symbol->var_declarations);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   802
  delete vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   803
  s4o.print("\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   804
  /* (A.3) Private internal variables */
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   805
  s4o.print(s4o.indent_spaces + "// PROGRAM private variables - TEMP, private and located variables\n");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   806
  vardecl = new generate_cc_vardecl_c(&s4o,
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   807
                generate_cc_vardecl_c::local_vf,
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   808
                generate_cc_vardecl_c::temp_vt |
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   809
                generate_cc_vardecl_c::private_vt |
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   810
                generate_cc_vardecl_c::located_vt |
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   811
                generate_cc_vardecl_c::external_vt);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   812
  vardecl->print(symbol->var_declarations);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   813
  delete vardecl;
18
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   814
  /* (A.4) Generate private internal variables for SFC */
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   815
  generate_cc_sfctables_c generate_cc_sfctables(&s4o);
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   816
  symbol->function_block_body->accept(generate_cc_sfctables);
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   817
  s4o.print("\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   818
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   819
  /* (A.5) Program data structure type name. */
12
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   820
  s4o.indent_left();
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   821
  s4o.print("} ");
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   822
  symbol->program_type_name->accept(*this);
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   823
  s4o.print(";\n\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   824
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   825
  /* (B) Constructor */
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   826
  /* (B.1) Constructor name... */
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   827
  s4o.print(s4o.indent_spaces + "void ");
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   828
  symbol->program_type_name->accept(*this);
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   829
  s4o.print(FB_INIT_SUFFIX);
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   830
  s4o.print("(");
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   831
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   832
  /* first and only parameter is a pointer to the data */
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   833
  symbol->program_type_name->accept(*this);
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   834
  s4o.print(" *");
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   835
  s4o.print(FB_FUNCTION_PARAM);
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   836
  s4o.print(") {\n");
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   837
  s4o.indent_right();
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   838
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   839
  /* (B.2) Member initializations... */
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   840
  s4o.print(s4o.indent_spaces);
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   841
  vardecl = new generate_cc_vardecl_c(&s4o,
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   842
  				      generate_cc_vardecl_c::constructorinit_vf,
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   843
  				      generate_cc_vardecl_c::input_vt |
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   844
  				      generate_cc_vardecl_c::output_vt |
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   845
  				      generate_cc_vardecl_c::inoutput_vt |
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   846
  				      generate_cc_vardecl_c::private_vt |
26
fd67f54e64e1 Now, LOCATED variables do declare extern C variables the same way EXTERNAL variables do.
etisserant
parents: 24
diff changeset
   847
  				      generate_cc_vardecl_c::located_vt |
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   848
				      generate_cc_vardecl_c::external_vt);
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   849
  vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   850
  delete vardecl;
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   851
  s4o.indent_left();
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   852
  s4o.print("\n" + s4o.indent_spaces + "}\n\n");
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   853
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   854
  /* (C) Function with PROGRAM body */
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   855
  /* (C.1) Step and Action definitions */
18
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   856
  generate_cc_sfcdecl_c generate_cc_sfcdecl(&s4o);
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   857
  symbol->function_block_body->accept(generate_cc_sfcdecl);
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   858
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   859
  /* (C.2) Function declaration */
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   860
  s4o.print("// Code part\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   861
  /* function interface */
12
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   862
  s4o.print("void ");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   863
  symbol->program_type_name->accept(*this);
12
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   864
  s4o.print(FB_FUNCTION_SUFFIX);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   865
  s4o.print("(");
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   866
  /* first and only parameter is a pointer to the data */
12
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   867
  symbol->program_type_name->accept(*this);
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   868
  s4o.print(" *");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   869
  s4o.print(FB_FUNCTION_PARAM);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   870
  s4o.print(") {\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   871
  s4o.indent_right();
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   872
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   873
  /* (C.3) Initialize TEMP variables */
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   874
  /* function body */
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   875
  s4o.print(s4o.indent_spaces + "// Initialise TEMP variables\n");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   876
  vardecl = new generate_cc_vardecl_c(&s4o,
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   877
  				      generate_cc_vardecl_c::init_vf,
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   878
				      generate_cc_vardecl_c::temp_vt);
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   879
  vardecl->print(symbol->var_declarations, NULL,  FB_FUNCTION_PARAM"->");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   880
  delete vardecl;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   881
  s4o.print("\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   882
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   883
  /* (C.4) Function code */
17
38754701ac41 SFC state machine first approach generator implemented
lbessard
parents: 16
diff changeset
   884
  generate_cc_SFC_IL_ST_c generate_cc_code(&s4o, symbol, FB_FUNCTION_PARAM"->");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   885
  symbol->function_block_body->accept(generate_cc_code);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   886
  s4o.indent_left();
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   887
  s4o.print(s4o.indent_spaces + "} // ");
12
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   888
  symbol->program_type_name->accept(*this);
f01522b04810 can now generate C programs instead off Cc
tib
parents: 0
diff changeset
   889
  s4o.print(FB_FUNCTION_SUFFIX);
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   890
  s4o.print(s4o.indent_spaces + "() \n\n");
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   891
24
7e830409f72a Adding init function on programs
etisserant
parents: 23
diff changeset
   892
  /* (C.5) Step and Action undefinitions */
18
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   893
  generate_cc_sfcundecl_c generate_cc_sfcundecl(&s4o);
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   894
  symbol->function_block_body->accept(generate_cc_sfcundecl);
e6af5eb5f546 SFC generator improved
lbessard
parents: 17
diff changeset
   895
16
e8b99f896416 Support for struct Time data Types manipulation into ST and IL added
lbessard
parents: 14
diff changeset
   896
  s4o.indent_left();
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   897
  s4o.print("\n\n\n\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   898
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   899
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   900
}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   901
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   902
}; /* generate_cc_pous_c */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   903
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   904
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   905
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   906
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   907
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   908
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   909
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   910
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   911
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   912
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   913
class generate_cc_config_c: public generate_cc_typedecl_c {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   914
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   915
    public:
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   916
    generate_cc_config_c(stage4out_c *s4o_ptr)
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   917
      : generate_cc_typedecl_c(s4o_ptr) {};
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   918
    virtual ~generate_cc_config_c(void) {}
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
   919
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   920
    typedef enum {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   921
      initprotos_dt,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   922
      initdeclare_dt,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   923
      runprotos_dt,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   924
      rundeclare_dt
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   925
    } declaretype_t;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   926
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   927
    declaretype_t wanted_declaretype;
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   928
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   929
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   930
/* B 1.7 Configuration elements */
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   931
/********************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   932
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   933
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   934
public:
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   935
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   936
CONFIGURATION configuration_name
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   937
   optional_global_var_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   938
   (resource_declaration_list | single_resource_declaration)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   939
   optional_access_declarations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   940
   optional_instance_specific_initializations
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   941
END_CONFIGURATION
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   942
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   943
/*
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   944
SYM_REF6(configuration_declaration_c, configuration_name, global_var_declarations, resource_declarations, access_declarations, instance_specific_initializations, unused)
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   945
*/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   946
void *visit(configuration_declaration_c *symbol) {
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   947
  generate_cc_vardecl_c *vardecl;
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   948
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   949
  /* (A) configuration declaration... */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   950
  /* (A.1) configuration name in comment */
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   951
  s4o.print("// CONFIGURATION ");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   952
  symbol->configuration_name->accept(*this);
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   953
  s4o.print("\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   954
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   955
  /* (A.2) Global variables */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   956
  vardecl = new generate_cc_vardecl_c(&s4o,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   957
  				      generate_cc_vardecl_c::local_vf,
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   958
  				      generate_cc_vardecl_c::global_vt);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   959
  vardecl->print(symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   960
  delete vardecl;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   961
  s4o.print("\n");
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   962
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   963
  /* (B) Initialisation Function */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   964
  /* (B.1) Ressources initialisation protos... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   965
  wanted_declaretype = initprotos_dt;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   966
  symbol->resource_declarations->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   967
  s4o.print("\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   968
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   969
  /* (B.2) Initialisation function name... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   970
  s4o.print(s4o.indent_spaces + "void config");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   971
  s4o.print(FB_INIT_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   972
  s4o.print("(void) {\n");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   973
  s4o.indent_right();
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   974
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   975
  /* (B.3) Global variables initializations... */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   976
  s4o.print(s4o.indent_spaces);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   977
  vardecl = new generate_cc_vardecl_c(&s4o,
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   978
  				      generate_cc_vardecl_c::constructorinit_vf,
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   979
  				      generate_cc_vardecl_c::global_vt);
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   980
  vardecl->print(symbol);
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   981
  delete vardecl;
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   982
  s4o.print("\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   983
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   984
  /* (B.3) Resources initializations... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   985
  wanted_declaretype = initdeclare_dt;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   986
  symbol->resource_declarations->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   987
  
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
   988
  s4o.indent_left();
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   989
  s4o.print(s4o.indent_spaces + "}\n\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   990
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   991
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   992
  /* (C) Run Function*/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   993
  /* (C.1) Resources run functions protos... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   994
  wanted_declaretype = runprotos_dt;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   995
  symbol->resource_declarations->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   996
  s4o.print("\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   997
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   998
  /* (C.2) Run function name... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
   999
  s4o.print(s4o.indent_spaces + "void config");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1000
  s4o.print(FB_RUN_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1001
  s4o.print("(int tick) {\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1002
  s4o.indent_right();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1003
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1004
  /* (C.3) Resources initializations... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1005
  wanted_declaretype = rundeclare_dt;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1006
  symbol->resource_declarations->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1007
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1008
  /* (C.3) Close Public Function body */
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1009
  s4o.indent_left();
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1010
  s4o.print(s4o.indent_spaces + "}\n");
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1011
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1012
  return NULL;
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1013
}
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1014
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1015
void *visit(resource_declaration_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1016
  if (wanted_declaretype == initprotos_dt || wanted_declaretype == runprotos_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1017
    s4o.print(s4o.indent_spaces + "void ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1018
    symbol->resource_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1019
    if (wanted_declaretype == initprotos_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1020
      s4o.print(FB_INIT_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1021
      s4o.print("(void);\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1022
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1023
    else {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1024
      s4o.print(FB_RUN_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1025
      s4o.print("(int tick);\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1026
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1027
  }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1028
  if (wanted_declaretype == initdeclare_dt || wanted_declaretype == rundeclare_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1029
    s4o.print(s4o.indent_spaces);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1030
    symbol->resource_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1031
    if (wanted_declaretype == initdeclare_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1032
      s4o.print(FB_INIT_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1033
      s4o.print("();\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1034
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1035
    else {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1036
      s4o.print(FB_RUN_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1037
      s4o.print("(tick);\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1038
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1039
  }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1040
  return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1041
}
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1042
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1043
void *visit(single_resource_declaration_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1044
  if (wanted_declaretype == initprotos_dt || wanted_declaretype == runprotos_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1045
    s4o.print(s4o.indent_spaces + "void RESOURCE");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1046
    if (wanted_declaretype == initprotos_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1047
      s4o.print(FB_INIT_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1048
      s4o.print("(void);\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1049
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1050
    else {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1051
      s4o.print(FB_RUN_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1052
      s4o.print("(int tick);\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1053
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1054
  }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1055
  if (wanted_declaretype == initdeclare_dt || wanted_declaretype == rundeclare_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1056
    s4o.print(s4o.indent_spaces + "RESOURCE");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1057
    if (wanted_declaretype == initdeclare_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1058
      s4o.print(FB_INIT_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1059
      s4o.print("();\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1060
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1061
    else {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1062
      s4o.print(FB_RUN_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1063
      s4o.print("(tick);\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1064
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1065
  }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1066
  return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1067
}
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1068
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1069
};
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1070
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1071
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1072
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1073
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1074
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1075
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1076
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1077
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1078
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1079
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1080
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1081
class generate_cc_resources_c: public generate_cc_typedecl_c {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1082
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1083
  search_var_instance_decl_c *search_config_instance;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1084
  search_var_instance_decl_c *search_resource_instance;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1085
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1086
  private:
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1087
    /* The name of the resource curretnly being processed... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1088
    symbol_c *current_resource_name;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1089
    symbol_c *current_global_vars;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1090
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1091
  public:
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1092
    generate_cc_resources_c(stage4out_c *s4o_ptr, symbol_c *config_scope, symbol_c *resource_scope, unsigned long time)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1093
      : generate_cc_typedecl_c(s4o_ptr) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1094
      search_config_instance = new search_var_instance_decl_c(config_scope);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1095
      search_resource_instance = new search_var_instance_decl_c(resource_scope);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1096
      common_ticktime = time;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1097
      current_resource_name = NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1098
      current_global_vars = NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1099
    };
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1100
    virtual ~generate_cc_resources_c(void) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1101
      delete search_config_instance;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1102
      delete search_resource_instance;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1103
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1104
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1105
    typedef enum {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1106
      declare_dt,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1107
      init_dt,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1108
      run_dt
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1109
    } declaretype_t;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1110
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1111
    declaretype_t wanted_declaretype;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1112
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1113
    unsigned long common_ticktime;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1114
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1115
    const char *current_program_name;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1116
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1117
    typedef enum {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1118
      assign_at,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1119
      send_at
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1120
    } assigntype_t;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1121
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1122
    assigntype_t wanted_assigntype;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1123
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1124
/********************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1125
/* B 1.7 Configuration elements */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1126
/********************************/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1127
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1128
/*
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1129
RESOURCE resource_name ON resource_type_name
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1130
   optional_global_var_declarations
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1131
   single_resource_declaration
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1132
END_RESOURCE
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1133
*/
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1134
// SYM_REF4(resource_declaration_c, resource_name, resource_type_name, global_var_declarations, resource_declaration)
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1135
    void *visit(resource_declaration_c *symbol) {
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1136
      current_resource_name = symbol->resource_name;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1137
      current_global_vars = symbol->global_var_declarations;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1138
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1139
      symbol->resource_declaration->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1140
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1141
      current_resource_name = NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1142
      current_global_vars = NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1143
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1144
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1145
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1146
/* task_configuration_list program_configuration_list */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1147
// SYM_REF2(single_resource_declaration_c, task_configuration_list, program_configuration_list)
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1148
    void *visit(single_resource_declaration_c *symbol) {
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1149
    	bool single_resource = current_resource_name == NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1150
      if (single_resource)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1151
        current_resource_name = new identifier_c("RESOURCE");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1152
      generate_cc_vardecl_c *vardecl;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1153
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1154
      /* (A) resource declaration... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1155
      /* (A.1) resource name in comment */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1156
      s4o.print("// RESOURCE ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1157
      current_resource_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1158
      s4o.print("\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1159
       
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1160
      /* (A.2) POUs inclusion */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1161
      s4o.print("#include \"POUS.c\"\n\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1162
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1163
      /* (A.3) Global variables... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1164
      if (current_global_vars != NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1165
        vardecl = new generate_cc_vardecl_c(&s4o,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1166
                      generate_cc_vardecl_c::local_vf,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1167
                      generate_cc_vardecl_c::global_vt);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1168
        vardecl->print(symbol);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1169
        delete vardecl;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1170
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1171
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1172
      /* (A.4) Resource programs declaration... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1173
      wanted_declaretype = declare_dt;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1174
      symbol->program_configuration_list->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1175
      s4o.print("\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1176
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1177
      /* (B) resource initialisation function... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1178
      /* (B.1) initialisation function name... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1179
      s4o.print("void ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1180
      current_resource_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1181
      s4o.print(FB_INIT_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1182
      s4o.print("(void) {\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1183
      s4o.indent_right();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1184
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1185
      /* (B.2) Global variables initialisations... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1186
      if (current_global_vars != NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1187
        s4o.print(s4o.indent_spaces);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1188
        vardecl = new generate_cc_vardecl_c(&s4o,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1189
                      generate_cc_vardecl_c::constructorinit_vf,
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1190
                      generate_cc_vardecl_c::global_vt);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1191
        vardecl->print(symbol);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1192
        delete vardecl;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1193
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1194
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1195
      /* (B.3) Resource programs initialisations... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1196
      wanted_declaretype = init_dt;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1197
      symbol->program_configuration_list->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1198
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1199
      s4o.indent_left();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1200
      s4o.print("}\n\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1201
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1202
      /* (C) Resource run function... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1203
      /* (C.1) Run function name... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1204
      s4o.print("void ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1205
      current_resource_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1206
      s4o.print(FB_RUN_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1207
      s4o.print("(int tick) {\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1208
      s4o.indent_right();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1209
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1210
      /* (C.2) Task management... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1211
      symbol->task_configuration_list->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1212
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1213
      /* (C.3) Program run declaration... */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1214
      wanted_declaretype = run_dt;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1215
      symbol->program_configuration_list->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1216
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1217
      s4o.indent_left();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1218
      s4o.print("}\n\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1219
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1220
      if (single_resource)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1221
        delete current_resource_name;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1222
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1223
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1224
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1225
/*  PROGRAM [RETAIN | NON_RETAIN] program_name [WITH task_name] ':' program_type_name ['(' prog_conf_elements ')'] */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1226
//SYM_REF6(program_configuration_c, retain_option, program_name, task_name, program_type_name, prog_conf_elements, unused)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1227
    void *visit(program_configuration_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1228
      if (wanted_declaretype == declare_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1229
        s4o.print(s4o.indent_spaces);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1230
        symbol->program_type_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1231
        s4o.print(" ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1232
        symbol->program_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1233
        s4o.print(";\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1234
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1235
      if (wanted_declaretype == init_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1236
        s4o.print(s4o.indent_spaces);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1237
        symbol->program_type_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1238
        s4o.print(FB_INIT_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1239
        s4o.print("(&");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1240
        symbol->program_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1241
        s4o.print(");\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1242
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1243
      if (wanted_declaretype == run_dt) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1244
        current_program_name = ((identifier_c*)(symbol->program_name))->value;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1245
        if (symbol->task_name != NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1246
          s4o.print(s4o.indent_spaces);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1247
          s4o.print("if (");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1248
          symbol->task_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1249
          s4o.print(") {\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1250
          s4o.indent_right(); 
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1251
        }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1252
        
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1253
        wanted_assigntype = assign_at;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1254
        symbol->prog_conf_elements->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1255
        
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1256
        s4o.print(s4o.indent_spaces);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1257
        symbol->program_type_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1258
        s4o.print(FB_FUNCTION_SUFFIX);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1259
        s4o.print("(&");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1260
        symbol->program_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1261
        s4o.print(");\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1262
        
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1263
        wanted_assigntype = send_at;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1264
        symbol->prog_conf_elements->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1265
        
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1266
        if (symbol->task_name != NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1267
          s4o.indent_left();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1268
          s4o.print(s4o.indent_spaces + "}\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1269
        }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1270
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1271
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1272
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1273
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1274
/*  TASK task_name task_initialization */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1275
//SYM_REF2(task_configuration_c, task_name, task_initialization)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1276
    void *visit(task_configuration_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1277
      s4o.print(s4o.indent_spaces + "int ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1278
      symbol->task_name->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1279
      s4o.print(" = ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1280
      symbol->task_initialization->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1281
      s4o.print(";\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1282
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1283
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1284
    
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1285
/*  '(' [SINGLE ASSIGN data_source ','] [INTERVAL ASSIGN data_source ','] PRIORITY ASSIGN integer ')' */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1286
//SYM_REF4(task_initialization_c, single_data_source, interval_data_source, priority_data_source, unused)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1287
    void *visit(task_initialization_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1288
      if (symbol->interval_data_source != NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1289
        calculate_time_c calculate_time;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1290
        symbol->interval_data_source->accept(calculate_time);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1291
        unsigned long time = calculate_time.get_time();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1292
        if (time != 0) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1293
          s4o.print("tick % ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1294
          s4o.print_integer((int)(time / common_ticktime));
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1295
        }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1296
        else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1297
          s4o.print("1");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1298
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1299
      else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1300
        s4o.print("1");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1301
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1302
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1303
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1304
/*  any_symbolic_variable ASSIGN prog_data_source */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1305
//SYM_REF2(prog_cnxn_assign_c, symbolic_variable, prog_data_source)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1306
    void *visit(prog_cnxn_assign_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1307
      if (wanted_assigntype == assign_at) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1308
        symbol_c *var_decl;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1309
        unsigned int vartype = 0;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1310
        symbol_c *current_var_reference = ((global_var_reference_c *)(symbol->prog_data_source))->global_var_name;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1311
        var_decl = search_resource_instance->get_decl(current_var_reference);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1312
        if (var_decl == NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1313
          var_decl = search_config_instance->get_decl(current_var_reference);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1314
          if (var_decl == NULL)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1315
            ERROR;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1316
          else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1317
            vartype = search_config_instance->get_vartype();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1318
        }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1319
        else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1320
          vartype = search_resource_instance->get_vartype();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1321
        
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1322
        s4o.print(s4o.indent_spaces + "{extern ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1323
        var_decl->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1324
        s4o.print(" ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1325
        symbol->prog_data_source->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1326
        s4o.print("; ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1327
        s4o.print(current_program_name);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1328
        s4o.print(".");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1329
        symbol->symbolic_variable->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1330
        s4o.print(" = ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1331
        if (vartype || search_var_instance_decl_c::global_vt)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1332
          s4o.print("*");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1333
        symbol->prog_data_source->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1334
        s4o.print(";}\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1335
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1336
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1337
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1338
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1339
/* any_symbolic_variable SENDTO data_sink */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1340
//SYM_REF2(prog_cnxn_sendto_c, symbolic_variable, data_sink)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1341
    void *visit(prog_cnxn_sendto_c *symbol) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1342
      if (wanted_assigntype == send_at) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1343
        symbol_c *var_decl;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1344
        unsigned int vartype = 0;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1345
        symbol_c *current_var_reference = ((global_var_reference_c *)(symbol->data_sink))->global_var_name;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1346
        var_decl = search_resource_instance->get_decl(current_var_reference);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1347
        if (var_decl == NULL) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1348
          var_decl = search_config_instance->get_decl(current_var_reference);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1349
          if (var_decl == NULL)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1350
            ERROR;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1351
          else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1352
            vartype = search_config_instance->get_vartype();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1353
        }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1354
        else
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1355
          vartype = search_resource_instance->get_vartype();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1356
        
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1357
        s4o.print(s4o.indent_spaces);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1358
        s4o.print(s4o.indent_spaces + "{extern ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1359
        var_decl->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1360
        s4o.print(" ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1361
        symbol->data_sink->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1362
        s4o.print("; ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1363
        if (vartype || search_var_instance_decl_c::global_vt)
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1364
          s4o.print("*");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1365
        symbol->data_sink->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1366
        s4o.print(" = ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1367
        s4o.print(current_program_name);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1368
        s4o.print(".");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1369
        symbol->symbolic_variable->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1370
        s4o.print("};\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1371
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1372
      return NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1373
    }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1374
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1375
};
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1376
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1377
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1378
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1379
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1380
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1381
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1382
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1383
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1384
/***********************************************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1385
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1386
class generate_cc_c: public iterator_visitor_c {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1387
  protected:
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1388
    stage4out_c &s4o;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1389
    stage4out_c pous_s4o;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1390
    generate_cc_pous_c generate_cc_pous;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1391
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1392
    symbol_c *current_configuration;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1393
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1394
    const char *current_name;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1395
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1396
    unsigned long common_ticktime;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1397
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1398
  public:
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1399
    generate_cc_c(stage4out_c *s4o_ptr): 
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1400
            s4o(*s4o_ptr),
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1401
            pous_s4o("POUS", "c"),
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1402
            generate_cc_pous(&pous_s4o) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1403
      current_configuration = NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1404
    }
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1405
            
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1406
    ~generate_cc_c(void) {}
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1407
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1408
/*************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1409
/* B.1 - Common elements */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1410
/*************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1411
/*******************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1412
/* B 1.1 - Letters, digits and identifiers */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1413
/*******************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1414
    void *visit(identifier_c *symbol) {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1415
    	current_name = symbol->value;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1416
    	return NULL;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1417
    }
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1418
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1419
/**************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1420
/* B.1.5 - Program organization units */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1421
/**************************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1422
/***********************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1423
/* B 1.5.1 - Functions */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1424
/***********************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1425
    void *visit(function_declaration_c *symbol) {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1426
    	symbol->accept(generate_cc_pous);
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1427
    	return NULL;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1428
    }
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1429
    
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1430
/*****************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1431
/* B 1.5.2 - Function Blocks */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1432
/*****************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1433
    void *visit(function_block_declaration_c *symbol) {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1434
    	symbol->accept(generate_cc_pous);
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1435
    	return NULL;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1436
    }
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1437
    
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1438
/**********************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1439
/* B 1.5.3 - Programs */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1440
/**********************/    
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1441
    void *visit(program_declaration_c *symbol) {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1442
    	symbol->accept(generate_cc_pous);
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1443
    	return NULL;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1444
    }
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1445
    
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1446
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1447
/********************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1448
/* B 1.7 Configuration elements */
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1449
/********************************/
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1450
    void *visit(configuration_declaration_c *symbol) {
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1451
  	  static int configuration_count = 0;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1452
  
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1453
      if (configuration_count++) {
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1454
        /* the first configuration is the one we will use!! */
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1455
        ERROR;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1456
      }
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1457
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1458
      current_configuration = symbol;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1459
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1460
      calculate_common_ticktime_c calculate_common_ticktime;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1461
      symbol->accept(calculate_common_ticktime);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1462
      common_ticktime = calculate_common_ticktime.get_ticktime();
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1463
      s4o.print("common_ticktime : ");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1464
      s4o.print_integer((int)(common_ticktime / 1000000));
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1465
      s4o.print("ms\n");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1466
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1467
      symbol->configuration_name->accept(*this);
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1468
    	stage4out_c config_s4o(current_name, "c");
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1469
    	generate_cc_config_c generate_cc_config(&config_s4o);
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1470
    	symbol->accept(generate_cc_config);
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1471
      symbol->resource_declarations->accept(*this);
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1472
    	
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1473
      current_configuration = NULL;
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1474
      
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1475
      return NULL;
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1476
    }
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1477
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1478
    void *visit(resource_declaration_c *symbol) {
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1479
    	symbol->resource_name->accept(*this);
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1480
    	stage4out_c resources_s4o(current_name, "c");
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1481
      generate_cc_resources_c generate_cc_resources(&resources_s4o, current_configuration, symbol, common_ticktime);
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1482
    	symbol->accept(generate_cc_resources);
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1483
    	return NULL;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1484
    }
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1485
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1486
    void *visit(single_resource_declaration_c *symbol) {
28
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1487
    	stage4out_c resources_s4o("RESOURCE", "c");
5b170c9ce134 Multi-file configuration and resource generation finished
lbessard
parents: 27
diff changeset
  1488
      generate_cc_resources_c generate_cc_resources(&resources_s4o, current_configuration, symbol, common_ticktime);
27
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1489
    	symbol->accept(generate_cc_resources);
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1490
    	return NULL;
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1491
    }
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1492
    
667721cf52c5 Now, stage4out can address files. Generate_cc have been split into one visitor per C file : pous, ressource and config. Work in progress.
etisserant
parents: 26
diff changeset
  1493
};
0
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1494
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1495
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1496
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1497
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1498
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1499
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1500
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1501
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1502
/***********************************************************************/
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1503
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1504
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1505
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1506
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1507
visitor_c *new_code_generator(stage4out_c *s4o)  {return new generate_cc_c(s4o);}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1508
void delete_code_generator(visitor_c *code_generator) {delete code_generator;}
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1509
fb772792efd1 Initial commit. Last MatPLC CVS with some makefile inclusion removed in order to compile fine out of MatPLC.
etisserant
parents:
diff changeset
  1510