Changeset 230 for branches/xpascal/Generators
- Timestamp:
- Jun 26, 2023, 12:08:45 PM (17 months ago)
- Location:
- branches/xpascal/Generators
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/xpascal/Generators/GeneratorCSharp.pas
r224 r230 129 129 if FunctionCall.Params.Count > 0 then begin 130 130 AddText('('); 131 for I := 0 to FunctionCall.Params.Count - 1 do 131 for I := 0 to FunctionCall.Params.Count - 1 do begin 132 if FunctionCall.FunctionDef.Params[I].Kind = pkVar then 133 AddText('ref '); 132 134 GenerateExpression(Block, TExpression(FunctionCall.Params[I])); 135 end; 133 136 AddText(')'); 134 137 end; … … 297 300 var 298 301 I: Integer; 302 Param: TFunctionParameter; 299 303 begin 300 304 GenerateTypeRef(FunctionDef.ResultType); 301 305 AddText(' ' + FunctionDef.Name + '('); 302 306 for I := 0 to FunctionDef.Params.Count - 1 do begin 303 GenerateTypeRef(TFunctionParameter(FunctionDef.Params[I]).TypeRef); 307 Param := TFunctionParameter(FunctionDef.Params[I]); 308 if Param.Kind = pkVar then AddText('ref '); 309 GenerateTypeRef(Param.TypeRef); 304 310 AddText(' '); 305 AddText( TFunctionParameter(FunctionDef.Params[I]).Name);311 AddText(Param.Name); 306 312 if I > 0 then AddText(', '); 307 313 end; … … 312 318 if FunctionDef.InternalName = 'WriteLn' then AddTextLine('Console.Write(Text + "\n");') 313 319 else if FunctionDef.InternalName = 'Write' then AddTextLine('Console.Write(Text);') 320 else if FunctionDef.InternalName = 'ReadLn' then AddTextLine('Text = Console.ReadLine();') 321 else if FunctionDef.InternalName = 'Read' then AddTextLine('Text = Console.ReadLine();') 314 322 else if FunctionDef.InternalName = 'IntToStr' then AddTextLine('return Value.ToString();') 315 323 else if FunctionDef.InternalName = 'StrToInt' then begin … … 319 327 AddTextLine(' return x;'); 320 328 AddTextLine('} else return 0;'); 329 end 330 else if FunctionDef.InternalName = 'BoolToStr' then AddTextLine('return Value.ToString();') 331 else if FunctionDef.InternalName = 'StrToBool' then begin 332 AddTextLine('bool x = false;'); 333 AddTextLine('if (bool.TryParse(Value, out x))'); 334 AddTextLine('{'); 335 AddTextLine(' return x;'); 336 AddTextLine('} else return false;'); 321 337 end; 322 338 -
branches/xpascal/Generators/GeneratorPascal.pas
r224 r230 231 231 else if FunctionDef.InternalName = 'Write' then AddTextLine('System.Write(Text);') 232 232 else if FunctionDef.InternalName = 'IntToStr' then AddTextLine('return SysUtils.IntToStr(Value);') 233 else if FunctionDef.InternalName = 'StrToInt' then AddTextLine('return SysUtils.StrToInt(Value);'); 233 else if FunctionDef.InternalName = 'StrToInt' then AddTextLine('return SysUtils.StrToInt(Value);') 234 else if FunctionDef.InternalName = 'BoolToStr' then AddTextLine('return SysUtils.BoolToStr(Value);') 235 else if FunctionDef.InternalName = 'StrToBool' then AddTextLine('return SysUtils.StrToBool(Value);'); 234 236 Indent := Indent - 1; 235 237 AddTextLine('end;'); -
branches/xpascal/Generators/GeneratorPhp.pas
r224 r230 241 241 else if FunctionDef.InternalName = 'Write' then AddTextLine('echo($Text);') 242 242 else if FunctionDef.InternalName = 'IntToStr' then AddTextLine('return $Value;') 243 else if FunctionDef.InternalName = 'StrToInt' then AddTextLine('return $Value;'); 243 else if FunctionDef.InternalName = 'StrToInt' then AddTextLine('return $Value;') 244 else if FunctionDef.InternalName = 'BoolToStr' then AddTextLine('return $Value;') 245 else if FunctionDef.InternalName = 'StrToBool' then AddTextLine('return $Value;'); 244 246 Indent := Indent - 1; 245 247 AddTextLine('}'); -
branches/xpascal/Generators/GeneratorXml.pas
r224 r230 11 11 TGeneratorXml = class(TGenerator) 12 12 private 13 procedure GenerateNodes(SourceNodes: TSourceNode s);13 procedure GenerateNodes(SourceNodes: TSourceNodeList<TSourceNode>); 14 14 procedure GenerateNode(SourceNode: TSourceNode); 15 15 public … … 21 21 implementation 22 22 23 resourcestring 24 SUnsupportedNodeType = 'Unsupported node type'; 25 23 26 { TGeneratorXml } 24 27 25 procedure TGeneratorXml.GenerateNodes(SourceNodes: TSourceNode s);28 procedure TGeneratorXml.GenerateNodes(SourceNodes: TSourceNodeList<TSourceNode>); 26 29 var 27 30 I: Integer; … … 30 33 if SourceNodes[I] is TSourceNode then begin 31 34 GenerateNode(TSourceNode(SourceNodes[I])); 32 end else raise Exception.Create( 'Unsupported node type');35 end else raise Exception.Create(SUnsupportedNodeType); 33 36 end; 34 37 end; … … 42 45 if SourceNode = nil then begin 43 46 end else 44 if SourceNode is TSourceNode sthen begin45 GenerateNodes(TSourceNode s(SourceNode))47 if SourceNode is TSourceNodeList<TSourceNode> then begin 48 GenerateNodes(TSourceNodeList<TSourceNode>(SourceNode)) 46 49 end else 47 50 if SourceNode is TSourceNode then begin … … 63 66 AddTextLine('</' + SourceNode.ClassName + '>'); 64 67 end else 65 raise Exception.Create( 'Unsupported node type');68 raise Exception.Create(SUnsupportedNodeType); 66 69 end; 67 70
Note:
See TracChangeset
for help on using the changeset viewer.