Changeset 67 for branches/Transpascal/Compiler/Produce/UProducerC.pas
- Timestamp:
- Oct 18, 2010, 12:39:37 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Transpascal/Compiler/Produce/UProducerC.pas
r60 r67 10 10 11 11 type 12 13 TProducerCDialect = (pdGCC, pdDynamicC); 12 14 13 15 { TProducerC } … … 35 37 function GenerateExpression(Expression: TExpression): string; 36 38 public 39 Dialect: TProducerCDialect; 37 40 TextSource: TStringList; 38 41 IndentationLength: Integer; … … 53 56 FileExtension := '.c'; 54 57 IndentationLength := 2; 58 Dialect := pdDynamicC; 55 59 end; 56 60 … … 104 108 begin 105 109 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"'); 107 113 Emit(''); 108 114 end; … … 110 116 procedure TProducerC.GenerateModule(Module: TModule); 111 117 begin 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"'); 118 120 Emit(''); 119 121 if Module is TModuleProgram then begin 122 TModuleProgram(Module).Body.Name := 'main'; 120 123 GenerateUses(TModuleProgram(Module).UsedModules); 121 124 GenerateCommonBlock(TModuleProgram(Module).Body, ''); … … 253 256 begin 254 257 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; 256 263 ntVariable: Result := Expression.Variable.Name; 257 264 ntFunction: Result := Expression.Method.Name;
Note:
See TracChangeset
for help on using the changeset viewer.