summaryrefslogtreecommitdiff
path: root/macros/CCodeGeneration/C_WhileExpression.sci
diff options
context:
space:
mode:
authorSiddhesh Wani2015-05-25 14:46:31 +0530
committerSiddhesh Wani2015-05-25 14:46:31 +0530
commitdb464f35f5a10b58d9ed1085e0b462689adee583 (patch)
treede5cdbc71a54765d9fec33414630ae2c8904c9b8 /macros/CCodeGeneration/C_WhileExpression.sci
downloadScilab2C_fossee_old-db464f35f5a10b58d9ed1085e0b462689adee583.tar.gz
Scilab2C_fossee_old-db464f35f5a10b58d9ed1085e0b462689adee583.tar.bz2
Scilab2C_fossee_old-db464f35f5a10b58d9ed1085e0b462689adee583.zip
Original Version
Diffstat (limited to 'macros/CCodeGeneration/C_WhileExpression.sci')
-rw-r--r--macros/CCodeGeneration/C_WhileExpression.sci93
1 files changed, 93 insertions, 0 deletions
diff --git a/macros/CCodeGeneration/C_WhileExpression.sci b/macros/CCodeGeneration/C_WhileExpression.sci
new file mode 100644
index 0000000..edd2830
--- /dev/null
+++ b/macros/CCodeGeneration/C_WhileExpression.sci
@@ -0,0 +1,93 @@
+function SharedInfo = C_WhileExpression(FileInfo,SharedInfo)
+// function SharedInfo = C_WhileExpression(FileInfo,SharedInfo)
+// -----------------------------------------------------------------
+// //NUT: add description here
+//
+// Input data:
+// //NUT: add description here
+//
+// Output data:
+// //NUT: add description here
+//
+// Status:
+// 15-Nov-2007 -- Raffaele Nutricato: Author.
+//
+// Copyright 2007 Raffaele Nutricato.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),2,2);
+
+// -----------------------
+// --- Initialization. ---
+// -----------------------
+nxtscifunname = SharedInfo.NextSCIFunName;
+nxtscifunnumber = SharedInfo.NextSCIFunNumber;
+
+ReportFileName = FileInfo.Funct(nxtscifunnumber).ReportFileName;
+CPass1FileName = FileInfo.Funct(nxtscifunnumber).CPass1FileName;
+
+CPass1WhileProlFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileProlFileName(SharedInfo.While.Level);
+CPass1WhileEpilFileName = FileInfo.Funct(nxtscifunnumber).CPass1WhileEpilFileName(SharedInfo.While.Level);
+CDeclarationFileName = FileInfo.Funct(nxtscifunnumber).CDeclarationFileName;
+
+// #RNU_RES_B
+PrintStringInfo(' ',ReportFileName,'file','y');
+PrintStringInfo('***Generating C code***',ReportFileName,'file','y');
+// #RNU_RES_E
+CCall ='';
+// ---------------------------
+// --- End Initialization. ---
+// ---------------------------
+
+// ----------------------------
+// --- Generate the C call. ---
+// ----------------------------
+
+// -------------------------
+// --- Manage all cases. ---
+// -------------------------
+PrintStringInfo(' Handling While Expression with OpColon.',ReportFileName,'file','y'); //NUT: sistema il commento.
+
+// -------------------------------------------------------------------------------------
+// --- Generate Prologue and Epilogue -> Copy the first N-1 lines of the for.c code. ---
+// -------------------------------------------------------------------------------------
+[C_Strings,NumCStrings] = File2StringArray(CPass1WhileProlFileName);
+C_Strings = stripblanks(C_Strings);
+for cntstr = 1:NumCStrings
+ // Prologue
+ PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+C_Strings(cntstr),CPass1FileName,'file','y','n');
+ // Epilogue
+ if (length(C_Strings(cntstr)) == 0)
+ C_Strings(cntstr) = ' '; // RNU for Bruno: If I don't do that I get a PrintStringInfo error related to mputstr.
+ // Function not defined for given argument type(s),
+ // check arguments or define function %0_mputstr for overloading.
+ end
+ PrintStringInfo(C_Strings(cntstr),CPass1WhileEpilFileName ,'file','y','n');
+end
+// ----------------------------------------
+// --- Insert "}" in the epilogue file. ---
+// ----------------------------------------
+PrintStringInfo('}',CPass1WhileEpilFileName ,'file','y');
+
+// ------------------------------
+// --- Insert for expression. ---
+// ------------------------------
+CCall = 'while('+SharedInfo.WhileExpr.CondVar+')';
+PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y');
+
+// -------------------
+// --- Insert "{". ---
+// -------------------
+CCall = '{';
+PrintStringInfo(C_IndentBlanks(SharedInfo.NIndent)+CCall,CPass1FileName,'file','y');
+
+// ---------------------------------
+// --- Update Indentation Level. ---
+// ---------------------------------
+SharedInfo.NIndent = SharedInfo.NIndent + 1;
+
+endfunction