doc_compile.cpp File Reference

#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <math.h>
#include "doc_compile.hh"
#include "sigtype.hh"
#include "floats.hh"
#include "sigprint.hh"
#include "sigtyperules.hh"
#include "recursivness.hh"
#include "simplify.hh"
#include "privatise.hh"
#include "prim2.hh"
#include "xtended.hh"
#include "compatibility.hh"
#include "ppsig.hh"
#include "names.hh"
#include "doc.hh"
#include "tlib.hh"
#include "doc_notice.hh"
Include dependency graph for doc_compile.cpp:

Go to the source code of this file.

Functions

bool getSigListNickName (Tree t, Tree &id)
static void extractMetadata (const string &fulllabel, string &label, map< string, set< string > > &metadata)
 Extracts metadata from a UI label : 'vol [unit: dB]' -> 'vol' + metadata map.
static string rmWhiteSpaces (const string &s)
 rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not those in the middle of the string)
static bool isVerySimpleFormula (Tree sig)
 Test if exp is very simple that is it can't be considered a real component.
static bool isSeparator (char c)
 tests if a charactere is a word separator
static string replaceTimeBy (const string &src, char r)
 Replaces the occurences of 't' in a formula with another character.

Variables

bool gLessTempSwitch
int gMaxCopyDelay
map< string, string > gDocMathStringMap
static const unsigned int MAX_RIGHT_MEMBER = 20
static const unsigned int MAX_SUB_EXPR = 10

Function Documentation

static void extractMetadata ( const string &  fulllabel,
string &  label,
map< string, set< string > > &  metadata 
) [static]

Extracts metadata from a UI label : 'vol [unit: dB]' -> 'vol' + metadata map.

Definition at line 1344 of file doc_compile.cpp.

References rmWhiteSpaces().

Referenced by DocCompiler::getUIDocInfos().

01345 {
01346     enum {kLabel, kEscape1, kEscape2, kEscape3, kKey, kValue};
01347     int state = kLabel; int deep = 0;
01348     string key, value;
01349     
01350     for (unsigned int i=0; i < fulllabel.size(); i++) {
01351         char c = fulllabel[i];
01352         switch (state) {
01353             case kLabel :
01354                 assert (deep == 0);
01355                 switch (c) {
01356                     case '\\' : state = kEscape1; break;
01357                     case '[' : state = kKey; deep++; break;
01358                     default : label += c;
01359                 }
01360                 break;
01361                 
01362             case kEscape1 :
01363                 label += c;
01364                 state = kLabel;
01365                 break;
01366                 
01367             case kEscape2 :
01368                 key += c;
01369                 state = kKey;
01370                 break;
01371                 
01372             case kEscape3 :
01373                 value += c;
01374                 state = kValue;
01375                 break;
01376                 
01377             case kKey :
01378                 assert (deep > 0);
01379                 switch (c) {
01380                     case '\\' :  state = kEscape2;
01381                         break;
01382                         
01383                     case '[' :  deep++;
01384                         key += c;
01385                         break;
01386                         
01387                     case ':' :  if (deep == 1) {
01388                         state = kValue;
01389                     } else {
01390                         key += c;
01391                     }
01392                         break;
01393                     case ']' :  deep--;
01394                         if (deep < 1) {
01395                             metadata[rmWhiteSpaces(key)].insert("");
01396                             state = kLabel;
01397                             key="";
01398                             value="";
01399                         } else {
01400                             key += c;
01401                         }
01402                         break;
01403                     default :   key += c;
01404                 }
01405                 break;
01406                 
01407             case kValue :
01408                 assert (deep > 0);
01409                 switch (c) {
01410                     case '\\' : state = kEscape3;
01411                         break;
01412                         
01413                     case '[' :  deep++;
01414                         value += c;
01415                         break;
01416                         
01417                     case ']' :  deep--;
01418                         if (deep < 1) {
01419                             metadata[rmWhiteSpaces(key)].insert(rmWhiteSpaces(value));
01420                             state = kLabel;
01421                             key="";
01422                             value="";
01423                         } else {
01424                             value += c;
01425                         }
01426                         break;
01427                     default :   value += c;
01428                 }
01429                 break;
01430                 
01431             default :
01432                 cerr << "ERROR unrecognized state (in extractMetadata) : " << state << endl;
01433         }
01434     }
01435     label = rmWhiteSpaces(label);
01436 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool getSigListNickName ( Tree  t,
Tree id 
)
static bool isSeparator ( char  c  )  [static]

tests if a charactere is a word separator

Definition at line 779 of file doc_compile.cpp.

Referenced by replaceTimeBy().

00780 {
00781     bool w = (  ((c >= 'a') && (c <='z'))
00782             ||  ((c >= 'A') && (c <='Z'))
00783             ||  ((c >= '0') && (c <='9'))
00784             );
00785 
00786     return ! w;
00787 }

Here is the caller graph for this function:

static bool isVerySimpleFormula ( Tree  sig  )  [static]

Test if exp is very simple that is it can't be considered a real component.

Parameters:
exp the signal we want to test
Returns:
true if it a very simple signal

Definition at line 502 of file doc_compile.cpp.

References isSigButton(), isSigCheckbox(), isSigFConst(), isSigHSlider(), isSigInput(), isSigInt(), isSigNumEntry(), isSigReal(), isSigVSlider(), and name().

Referenced by DocCompiler::generateCacheCode().

00503 {
00504     int     i;
00505     double  r;
00506     Tree    type, name, file, label, c, x, y, z;
00507     
00508     return  isSigInt(sig, &i) 
00509     ||  isSigReal(sig, &r)
00510     ||  isSigInput(sig, &i)
00511     ||  isSigFConst(sig, type, name, file)
00512     ||  isSigButton(sig, label)
00513     ||  isSigCheckbox(sig, label)
00514     ||  isSigVSlider(sig, label,c,x,y,z)
00515     ||  isSigHSlider(sig, label,c,x,y,z)
00516     ||  isSigNumEntry(sig, label,c,x,y,z)
00517     ;
00518 }

Here is the call graph for this function:

Here is the caller graph for this function:

static string replaceTimeBy ( const string &  src,
char  r 
) [static]

Replaces the occurences of 't' in a formula with another character.

Definition at line 793 of file doc_compile.cpp.

References isSeparator().

Referenced by DocCompiler::generateDocWriteTbl().

00794 {
00795     string  dst;
00796     char    pre = 0;
00797     for (size_t i=0; i < src.size(); i++)
00798     {
00799         char x = src[i];
00800         if ((x=='t') && isSeparator(pre) && ((i == src.size()-1) || isSeparator(src[i+1]))) {
00801             dst.push_back(r);
00802         } else {
00803             dst.push_back(x);
00804         }
00805         pre = x;
00806     }
00807     return dst;
00808 }

Here is the call graph for this function:

Here is the caller graph for this function:

static string rmWhiteSpaces ( const string &  s  )  [static]

rmWhiteSpaces(): Remove the leading and trailing white spaces of a string (but not those in the middle of the string)

Definition at line 1443 of file doc_compile.cpp.

Referenced by extractMetadata().

01444 {
01445     size_t i = s.find_first_not_of(" \t");
01446     size_t j = s.find_last_not_of(" \t");
01447     
01448     if ( (i != string::npos) & (j != string::npos) ) {
01449         return s.substr(i, 1+j-i);
01450     } else {
01451         return "";
01452     }
01453 }

Here is the caller graph for this function:


Variable Documentation

map<string, string> gDocMathStringMap

Definition at line 123 of file main.cpp.

Referenced by process_cmdline().

const unsigned int MAX_RIGHT_MEMBER = 20 [static]

Definition at line 65 of file doc_compile.cpp.

const unsigned int MAX_SUB_EXPR = 10 [static]

Definition at line 66 of file doc_compile.cpp.

Generated on Wed Apr 28 23:45:47 2010 for FAUST compiler by  doxygen 1.6.3