?login_element?

Subversion Repositories NedoOS

Rev

Rev 472 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #include <stdio.h>
  5. #include <io.h>
  6. #pragma hdrstop
  7.  
  8. #include "guiUnit1.h"
  9. //---------------------------------------------------------------------------
  10. #pragma package(smart_init)
  11. #pragma resource "*.dfm"
  12.  
  13. TForm1 *Form1;
  14. //FILE *fin;
  15. //FILE *fout;
  16. //FILE *fhint;
  17. //FILE *ferr;
  18. FILE *fmemo;
  19.  
  20. //#include "compiler.hpp"
  21.  
  22. //#include "globals.cpp"
  23. /*
  24. int ord(char c)
  25. {
  26.   return (int)c;
  27. }
  28.  
  29. int Length(AnsiString s)
  30. {
  31.   return s.Length();
  32. }
  33.  
  34. char read(FILE *file)
  35. {
  36.   char c;
  37.   fread( &c, sizeof(c), 1, fin);
  38.   return c;
  39. }
  40.  
  41. void write(FILE *file, char c)
  42. {
  43.   //fwrite(&c,sizeof(c),1,file);
  44.   fprintf(file,"%c",c);
  45. }
  46.  
  47. bool eof(FILE *file)
  48. {
  49.   return curline>50;
  50. }
  51.  
  52. void write(FILE *file, AnsiString s)
  53. {
  54.   fprintf(file,"%s",s.c_str());
  55. }
  56. */
  57.  
  58. //#include "typecodes.cpp"
  59. //#include "emitter.cpp"
  60. //#include "emits.cpp"
  61. //#include "reads.cpp"
  62. //#include "emitdirectives.cpp"
  63. //#include "regs.cpp"
  64. //#include "doasm.cpp"
  65. //#include "emitcommands.cpp"
  66. //#include "compiler.cpp"
  67.  
  68.  
  69. //---------------------------------------------------------------------------
  70. __fastcall TForm1::TForm1(TComponent* Owner)
  71.         : TForm(Owner)
  72. {
  73. }
  74. //---------------------------------------------------------------------------
  75.  
  76. void __fastcall TForm1::memoInChange(TObject *Sender)
  77. {
  78.   int linr;
  79.   byte digit[6];
  80.   AnsiString caption;
  81.   linr=memoIn->CaretPos.y+1;
  82.   //digit[0]=typeshift[1];
  83.   digit[1]=linr/10000; linr=linr-digit[1]*10000; digit[1]=digit[1]+48; //'0'
  84.   digit[2]=linr/1000;  linr=linr-digit[2]*1000;  digit[2]=digit[2]+48; //'0'
  85.   digit[3]=linr/100;   linr=linr-digit[3]*100;   digit[3]=digit[3]+48; //'0'
  86.   digit[4]=linr/10;    linr=linr-digit[4]*10;    digit[4]=digit[4]+48; //'0'
  87.   digit[5]=linr;                                 digit[5]=digit[5]+48; //'0'
  88.   caption="Line=";
  89.   caption=caption+(char)(digit[1])+(char)(digit[2])+(char)(digit[3])+(char)(digit[4])+(char)(digit[5]); //IntToStr(MemoIn.CaretPos.Y+1);
  90.   lbCaretPos->Caption=caption;
  91. }
  92. //---------------------------------------------------------------------------
  93.  
  94. void __fastcall TForm1::memoInMouseDown(TObject *Sender,
  95.       TMouseButton Button, TShiftState Shift, int X, int Y)
  96. {
  97.   memoInChange(Sender);
  98. }
  99. //---------------------------------------------------------------------------
  100. void __fastcall TForm1::memoInKeyDown(TObject *Sender, WORD &Key,
  101.       TShiftState Shift)
  102. {
  103.   memoInChange(Sender);
  104.   if ((Key!=VK_LEFT)&&(Key!=VK_RIGHT)&&(Key!=VK_UP)&&(Key!=VK_DOWN))
  105.     if (cbAuto->Checked) Button1Click(Sender);
  106. }
  107. //---------------------------------------------------------------------------
  108. void __fastcall TForm1::Button1Click(TObject *Sender)
  109. {
  110.   AnsiString s;
  111.   //char line[100000];
  112.   //setasms(cbAsm->Checked);
  113.   //setcomments(cbComments->Checked);
  114.   //sethints(cbHints->Checked);
  115.   memoIn->Lines->SaveToFile("_test.c");
  116.   //fmemo=fopen("fin","wt");
  117.   //s=memoIn->Lines->Text;
  118.   //fwrite(fmemo,s);
  119.   //fclose(fmemo);
  120.   //memoOut->Clear();
  121.   //memoErr->Clear();
  122.   //fin=fopen("fin","rt");
  123.   //setfout('fout'); //AssignFile(fout,'fout'); Rewrite(fout);
  124.   //setfhint('fouthints'); //AssignFile(fhint,'fouthints'); Rewrite(fhint);
  125.   //setferr('ferr'); //AssignFile(ferr,'ferr'); Rewrite(ferr);
  126. //  if (cbARM->Checked) {
  127.   switch (rgTarget->ItemIndex) {
  128.   case 0:
  129.     s="..\\_sdk\\nedolang.exe";
  130.     break;
  131.   case 1:
  132.     s="..\\_sdk\\nedolarm.exe";
  133.     break;
  134.   case 2:
  135.     s="..\\_sdk\\nedol386.exe";
  136.     break;
  137.   default:
  138.     s="..\\_sdk\\nedolspt.exe";
  139.   };
  140. //  if(!cbAsm->Checked) s=s+" -a";
  141.   if(cbComments->Checked) s=s+" -C";
  142.   if(cbHints->Checked) s=s+" -H";
  143.   s=s+" _test.c";
  144.   system(s.c_str()); //compile();
  145.   //closeferr; //CloseFile(ferr);
  146.   //closefhint; //CloseFile(fhint);
  147.   //closefout; //CloseFile(fout);
  148.   //fclose(fin);
  149.   //fmemo=fopen("fout","rt");
  150.   //memoOut->Hide();
  151.  
  152.   try {
  153.     memoOut->Lines->LoadFromFile("_test.ast");
  154.   } catch (Exception &e){
  155.   };
  156.  
  157. /*  while (fgets(line,sizeof(line),fmemo)!=NULL) {
  158.     line[StrLen(line)-1]='\0';
  159.     memoOut->Lines->Add(line);
  160.   };*/
  161.   //memoOut->Show();
  162.   //fclose(fmemo);
  163.   fmemo=fopen("err.f","rt");
  164.   if (fmemo) {
  165.     fclose(fmemo);
  166.   //memoErr->Hide();
  167.     memoErr->Lines->LoadFromFile("err.f");
  168.   }else {
  169.     fclose(fmemo);
  170.   };
  171. /*  while (fgets(line,sizeof(line),fmemo)!=NULL) {
  172.     line[StrLen(line)-1]='\0';
  173.     memoErr->Lines->Add(line);
  174.   };*/
  175.   //memoErr->Show();
  176. }
  177. //---------------------------------------------------------------------------
  178.  
  179. void __fastcall TForm1::FormCreate(TObject *Sender)
  180. {
  181.   //AnsiString s;
  182.   //char line[100000];
  183.   //memoIn->Clear();
  184.   //fmemo=fopen("fin","rt");
  185.   //memoIn->Hide();
  186.   system("..\\_sdk\\nedolang.exe _test.c");
  187.   memoIn->Lines->LoadFromFile("_test.c");
  188. /*  while (fgets(line,sizeof(line),fmemo)!=NULL) {
  189.     line[StrLen(line)-1]='\0';
  190.     memoIn->Lines->Add(line);
  191.   };*/
  192.   //memoIn->Show();
  193.   //fclose(fmemo);
  194.   Button1Click(Sender);
  195. }
  196. //---------------------------------------------------------------------------
  197.  
  198. void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
  199. {
  200.   memoIn->Lines->SaveToFile("_test.c");
  201. }
  202. //---------------------------------------------------------------------------
  203.  
  204.