Ignore:
Timestamp:
Oct 18, 2010, 12:39:37 PM (14 years ago)
Author:
george
Message:
  • Fixed: Parsing of strings.
  • Modified: Now supported C target "Dynamic C" dialect.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Transpascal/Compiler/Produce/UProducerC.pas

    r60 r67  
    1010
    1111type
     12
     13  TProducerCDialect = (pdGCC, pdDynamicC);
    1214
    1315  { TProducerC }
     
    3537    function GenerateExpression(Expression: TExpression): string;
    3638  public
     39    Dialect: TProducerCDialect;
    3740    TextSource: TStringList;
    3841    IndentationLength: Integer;
     
    5356  FileExtension := '.c';
    5457  IndentationLength := 2;
     58  Dialect := pdDynamicC;
    5559end;
    5660
     
    104108begin
    105109  for I := 0 to UsedModules.Count - 1 do
    106     Emit('#include "' + TUsedModule(UsedModules[I]).Name + '.h"');
     110    if Dialect = pdDynamicC then
     111      Emit('#use "' + TUsedModule(UsedModules[I]).Name + '.lib"')
     112      else Emit('#include "' + TUsedModule(UsedModules[I]).Name + '.h"');
    107113  Emit('');
    108114end;
     
    110116procedure TProducerC.GenerateModule(Module: TModule);
    111117begin
    112   Emit('#define int8 char');
    113   Emit('#define int16 int');
    114   Emit('#define int32 long');
    115   Emit('#define uint8 unsigned char');
    116   Emit('#define uint16 unsigned int');
    117   Emit('#define uint32 unsigned long');
     118  if Dialect = pdDynamicC then Emit('#use "platform.lib"')
     119    else Emit('#include "platform.h"');
    118120  Emit('');
    119121  if Module is TModuleProgram then begin
     122    TModuleProgram(Module).Body.Name := 'main';
    120123    GenerateUses(TModuleProgram(Module).UsedModules);
    121124    GenerateCommonBlock(TModuleProgram(Module).Body, '');
     
    253256begin
    254257  case Expression.NodeType of
    255     ntConstant: Result := Expression.Value;
     258    ntConstant: begin
     259      if VarType(Expression.Value) = varString then
     260        Result := '"' + Expression.Value + '"'
     261        else Result := Expression.Value;
     262    end;
    256263    ntVariable: Result := Expression.Variable.Name;
    257264    ntFunction: Result := Expression.Method.Name;
Note: See TracChangeset for help on using the changeset viewer.