Changeset 39 for branches/DelphiToC
- Timestamp:
- Aug 5, 2010, 9:51:16 AM (14 years ago)
- Location:
- branches/DelphiToC
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/Analyze/UPascalParser.pas
r38 r39 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls,UPascalSource, FileUtil;9 Dialogs, UPascalSource, FileUtil; 10 10 11 11 type … … 254 254 with Parser do begin 255 255 Expect('while'); 256 Condition.CommonBlock := CommonBlock; 256 257 TParserExpression(Condition).Parse(Parser); 257 258 Expect('do'); … … 282 283 if Identifier = '(' then begin 283 284 // Subexpression 284 with TExpression(Expressions [Expressions.Count - 1]) do begin285 with TExpression(Expressions.Last) do begin 285 286 SubItems[1] := TExpression.Create; 286 287 TParserExpression(SubItems[1]).Parse(Parser); 287 288 end; 288 289 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 290 CommonBlock := Self.CommonBlock; 289 291 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 290 292 end; … … 293 295 if IsOperator(Identifier) then begin 294 296 // Operator 295 TExpression(Expressions [Expressions.Count - 1]).OperatorName := Identifier;296 TExpression(Expressions [Expressions.Count - 1]).NodeType := ntOperator;297 TExpression(Expressions.Last).OperatorName := Identifier; 298 TExpression(Expressions.Last).NodeType := ntOperator; 297 299 end else 298 300 if IsIdentificator(Identifier) then begin … … 301 303 if Assigned(NewVariable) then begin 302 304 // Referenced variable 303 with TExpression(Expressions [Expressions.Count - 1]) do begin305 with TExpression(Expressions.Last) do begin 304 306 SubItems[1] := TExpression.Create; 305 307 TExpression(SubItems[1]).NodeType := ntVariable; … … 307 309 end; 308 310 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 311 CommonBlock := Self.CommonBlock; 309 312 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 310 313 end; … … 313 316 if Assigned(Method) then begin 314 317 // Referenced method 315 with TExpression(Expressions [Expressions.Count - 1]) do begin318 with TExpression(Expressions.Last) do begin 316 319 SubItems[1] := TExpression.Create; 317 320 if NextCode = '(' then // Method with parameters … … 331 334 Expect(')'); 332 335 end; 333 TExpression(SubItems[1]).NodeType := n TFunction;336 TExpression(SubItems[1]).NodeType := ntFunction; 334 337 TExpression(SubItems[1]).Method := Method; 335 338 end; 336 339 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 340 CommonBlock := Self.CommonBlock; 337 341 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 338 342 end; … … 341 345 if Assigned(Constant) then begin 342 346 // Referenced constant 343 with TExpression(Expressions [Expressions.Count - 1]) do begin347 with TExpression(Expressions.Last) do begin 344 348 SubItems[1] := TExpression.Create; 345 349 TExpression(SubItems[1]).NodeType := ntConstant; … … 347 351 end; 348 352 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 353 CommonBlock := Self.CommonBlock; 349 354 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 350 355 end; … … 357 362 begin 358 363 // Constant value 359 with TExpression(Expressions [Expressions.Count - 1]) do begin364 with TExpression(Expressions.Last) do begin 360 365 SubItems[1] := TExpression.Create; 366 TExpression(SubItems[1]).CommonBlock := Self.CommonBlock; 361 367 TExpression(SubItems[1]).NodeType := ntConstant; 362 368 … … 367 373 // TExpression(SubItems[1]).Value[I - 1] := Byte(Identifier[I]); 368 374 end else begin 369 //SetLength(TExpression(SubItems[1]).Value, 1); 370 //TExpression(SubItems[1]).Value[0] := StrToInt(Identifier); 375 TExpression(SubItems[1]).Value := Identifier; 371 376 end; 372 377 end; 378 //ShowMessage(IntToStr(Expressions.Count)); 373 379 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do begin 380 CommonBlock := Self.CommonBlock; 374 381 SubItems[0] := TExpression(Expressions[Expressions.Count - 2]).SubItems[1]; 375 382 end; … … 386 393 TExpression(Expressions[I - 1]).SubItems[1] := Expressions[I]; 387 394 TExpression(Expressions[I + 1]).SubItems[0] := Expressions[I]; 388 Expressions.Delete(I);395 //Expressions.Delete(I); 389 396 end else Inc(I); 390 397 end; 391 398 end; 392 399 end; 393 Result := TExpression(TExpression(Expressions[0]).SubItems[1]); 394 TExpression(Expressions[0]).SubItems[1] := nil; 400 Assign(TExpression(TExpression(Expressions.First).SubItems[1])); 401 TExpression(Expressions.First).SubItems[1] := nil; 402 //ShowMessage(IntToStr(Expressions.Count)); 395 403 TExpression(Expressions[1]).SubItems[0] := nil; 396 404 Expressions.Destroy; -
branches/DelphiToC/DelphiToC.lpi
r38 r39 44 44 <TopLine Value="3"/> 45 45 <CursorPos X="39" Y="12"/> 46 <UsageCount Value="5 4"/>46 <UsageCount Value="56"/> 47 47 <Loaded Value="True"/> 48 48 </Unit0> … … 56 56 <EditorIndex Value="6"/> 57 57 <WindowIndex Value="0"/> 58 <TopLine Value=" 42"/>59 <CursorPos X=" 17" Y="49"/>60 <UsageCount Value="5 4"/>58 <TopLine Value="10"/> 59 <CursorPos X="46" Y="23"/> 60 <UsageCount Value="56"/> 61 61 <Loaded Value="True"/> 62 62 <LoadedDesigner Value="True"/> … … 69 69 <TopLine Value="1"/> 70 70 <CursorPos X="1" Y="1"/> 71 <UsageCount Value="5 4"/>71 <UsageCount Value="56"/> 72 72 </Unit2> 73 73 <Unit3> … … 77 77 <EditorIndex Value="4"/> 78 78 <WindowIndex Value="0"/> 79 <TopLine Value=" 189"/>80 <CursorPos X=" 14" Y="205"/>81 <UsageCount Value="5 4"/>79 <TopLine Value="470"/> 80 <CursorPos X="3" Y="483"/> 81 <UsageCount Value="56"/> 82 82 <Loaded Value="True"/> 83 83 </Unit3> … … 88 88 <EditorIndex Value="8"/> 89 89 <WindowIndex Value="0"/> 90 <TopLine Value="1 "/>91 <CursorPos X=" 14" Y="9"/>92 <UsageCount Value="5 4"/>90 <TopLine Value="10"/> 91 <CursorPos X="73" Y="9"/> 92 <UsageCount Value="56"/> 93 93 <Loaded Value="True"/> 94 94 </Unit4> … … 100 100 <TopLine Value="1"/> 101 101 <CursorPos X="1" Y="1"/> 102 <UsageCount Value="5 4"/>102 <UsageCount Value="56"/> 103 103 </Unit5> 104 104 <Unit6> … … 109 109 <TopLine Value="1"/> 110 110 <CursorPos X="1" Y="1"/> 111 <UsageCount Value="5 4"/>111 <UsageCount Value="56"/> 112 112 </Unit6> 113 113 <Unit7> … … 119 119 <TopLine Value="3"/> 120 120 <CursorPos X="3" Y="8"/> 121 <UsageCount Value="5 4"/>121 <UsageCount Value="56"/> 122 122 <Loaded Value="True"/> 123 123 </Unit7> … … 129 129 <EditorIndex Value="0"/> 130 130 <WindowIndex Value="0"/> 131 <TopLine Value=" 75"/>132 <CursorPos X=" 47" Y="96"/>133 <UsageCount Value="5 4"/>131 <TopLine Value="382"/> 132 <CursorPos X="37" Y="396"/> 133 <UsageCount Value="56"/> 134 134 <Loaded Value="True"/> 135 135 </Unit8> … … 139 139 <TopLine Value="1"/> 140 140 <CursorPos X="1" Y="1"/> 141 <UsageCount Value=" 7"/>141 <UsageCount Value="6"/> 142 142 <DefaultSyntaxHighlighter Value="LFM"/> 143 143 </Unit9> … … 147 147 <EditorIndex Value="5"/> 148 148 <WindowIndex Value="0"/> 149 <TopLine Value="6 7"/>150 <CursorPos X="1 7" Y="80"/>151 <UsageCount Value="2 7"/>149 <TopLine Value="68"/> 150 <CursorPos X="14" Y="90"/> 151 <UsageCount Value="28"/> 152 152 <Loaded Value="True"/> 153 153 </Unit10> … … 166 166 <TopLine Value="55"/> 167 167 <CursorPos X="7" Y="68"/> 168 <UsageCount Value="1 0"/>168 <UsageCount Value="11"/> 169 169 <Loaded Value="True"/> 170 170 </Unit12> … … 175 175 <TopLine Value="139"/> 176 176 <CursorPos X="16" Y="146"/> 177 <UsageCount Value="1 0"/>177 <UsageCount Value="11"/> 178 178 <Loaded Value="True"/> 179 179 </Unit13> … … 184 184 <TopLine Value="934"/> 185 185 <CursorPos X="10" Y="947"/> 186 <UsageCount Value="1 0"/>186 <UsageCount Value="11"/> 187 187 <Loaded Value="True"/> 188 188 </Unit14> … … 191 191 <Position1> 192 192 <Filename Value="Analyze\UPascalParser.pas"/> 193 <Caret Line=" 274" Column="1" TopLine="255"/>193 <Caret Line="395" Column="1" TopLine="388"/> 194 194 </Position1> 195 195 <Position2> 196 196 <Filename Value="Analyze\UPascalParser.pas"/> 197 <Caret Line=" 275" Column="1" TopLine="258"/>197 <Caret Line="389" Column="1" TopLine="384"/> 198 198 </Position2> 199 199 <Position3> 200 200 <Filename Value="Analyze\UPascalParser.pas"/> 201 <Caret Line=" 284" Column="1" TopLine="271"/>201 <Caret Line="387" Column="1" TopLine="382"/> 202 202 </Position3> 203 203 <Position4> 204 <Filename Value=" Analyze\UPascalParser.pas"/>205 <Caret Line=" 288" Column="1" TopLine="271"/>204 <Filename Value="UPascalSource.pas"/> 205 <Caret Line="478" Column="23" TopLine="470"/> 206 206 </Position4> 207 207 <Position5> 208 208 <Filename Value="Analyze\UPascalParser.pas"/> 209 <Caret Line="3 44" Column="1" TopLine="331"/>209 <Caret Line="392" Column="39" TopLine="382"/> 210 210 </Position5> 211 211 <Position6> 212 212 <Filename Value="Analyze\UPascalParser.pas"/> 213 <Caret Line="3 45" Column="1" TopLine="331"/>213 <Caret Line="393" Column="1" TopLine="382"/> 214 214 </Position6> 215 215 <Position7> 216 216 <Filename Value="Analyze\UPascalParser.pas"/> 217 <Caret Line=" 270" Column="25" TopLine="251"/>217 <Caret Line="394" Column="1" TopLine="382"/> 218 218 </Position7> 219 219 <Position8> 220 220 <Filename Value="Analyze\UPascalParser.pas"/> 221 <Caret Line="3 84" Column="10" TopLine="365"/>221 <Caret Line="395" Column="1" TopLine="382"/> 222 222 </Position8> 223 223 <Position9> 224 224 <Filename Value="Analyze\UPascalParser.pas"/> 225 <Caret Line=" 269" Column="9" TopLine="255"/>225 <Caret Line="389" Column="1" TopLine="382"/> 226 226 </Position9> 227 227 <Position10> 228 228 <Filename Value="Analyze\UPascalParser.pas"/> 229 <Caret Line=" 287" Column="29" TopLine="273"/>229 <Caret Line="387" Column="1" TopLine="382"/> 230 230 </Position10> 231 231 <Position11> 232 232 <Filename Value="Analyze\UPascalParser.pas"/> 233 <Caret Line=" 95" Column="24" TopLine="86"/>233 <Caret Line="388" Column="1" TopLine="382"/> 234 234 </Position11> 235 235 <Position12> 236 236 <Filename Value="Analyze\UPascalParser.pas"/> 237 <Caret Line="3 48" Column="24" TopLine="335"/>237 <Caret Line="389" Column="1" TopLine="382"/> 238 238 </Position12> 239 239 <Position13> 240 240 <Filename Value="Analyze\UPascalParser.pas"/> 241 <Caret Line=" 102" Column="24" TopLine="99"/>241 <Caret Line="400" Column="1" TopLine="382"/> 242 242 </Position13> 243 243 <Position14> 244 <Filename Value=" Analyze\UPascalParser.pas"/>245 <Caret Line=" 99" Column="38" TopLine="99"/>244 <Filename Value="UPascalSource.pas"/> 245 <Caret Line="485" Column="1" TopLine="470"/> 246 246 </Position14> 247 247 <Position15> 248 248 <Filename Value="Analyze\UPascalParser.pas"/> 249 <Caret Line=" 75" Column="79" TopLine="74"/>249 <Caret Line="392" Column="1" TopLine="382"/> 250 250 </Position15> 251 251 <Position16> 252 252 <Filename Value="Analyze\UPascalParser.pas"/> 253 <Caret Line=" 102" Column="24" TopLine="88"/>253 <Caret Line="393" Column="1" TopLine="382"/> 254 254 </Position16> 255 255 <Position17> 256 <Filename Value=" E:\Programy\Lazarus\fpc\2.4.0\source\rtl\objpas\sysutils\sysutils.inc"/>257 <Caret Line=" 146" Column="16" TopLine="139"/>256 <Filename Value="Analyze\UPascalParser.pas"/> 257 <Caret Line="394" Column="1" TopLine="382"/> 258 258 </Position17> 259 259 <Position18> 260 260 <Filename Value="Analyze\UPascalParser.pas"/> 261 <Caret Line=" 99" Column="47" TopLine="89"/>261 <Caret Line="395" Column="1" TopLine="382"/> 262 262 </Position18> 263 263 <Position19> 264 264 <Filename Value="Analyze\UPascalParser.pas"/> 265 <Caret Line=" 75" Column="37" TopLine="74"/>265 <Caret Line="389" Column="1" TopLine="382"/> 266 266 </Position19> 267 267 <Position20> 268 268 <Filename Value="Analyze\UPascalParser.pas"/> 269 <Caret Line=" 96" Column="54" TopLine="75"/>269 <Caret Line="387" Column="1" TopLine="382"/> 270 270 </Position20> 271 271 <Position21> 272 272 <Filename Value="Analyze\UPascalParser.pas"/> 273 <Caret Line=" 97" Column="52" TopLine="92"/>273 <Caret Line="388" Column="1" TopLine="382"/> 274 274 </Position21> 275 275 <Position22> 276 276 <Filename Value="Analyze\UPascalParser.pas"/> 277 <Caret Line=" 720" Column="47" TopLine="707"/>277 <Caret Line="389" Column="1" TopLine="382"/> 278 278 </Position22> 279 279 <Position23> 280 280 <Filename Value="Analyze\UPascalParser.pas"/> 281 <Caret Line=" 97" Column="3" TopLine="84"/>281 <Caret Line="387" Column="1" TopLine="382"/> 282 282 </Position23> 283 283 <Position24> 284 284 <Filename Value="Analyze\UPascalParser.pas"/> 285 <Caret Line=" 720" Column="58" TopLine="707"/>285 <Caret Line="388" Column="1" TopLine="382"/> 286 286 </Position24> 287 287 <Position25> 288 288 <Filename Value="Analyze\UPascalParser.pas"/> 289 <Caret Line=" 95" Column="52" TopLine="91"/>289 <Caret Line="400" Column="1" TopLine="382"/> 290 290 </Position25> 291 291 <Position26> 292 <Filename Value=" Analyze\UPascalParser.pas"/>293 <Caret Line=" 778" Column="33" TopLine="765"/>292 <Filename Value="UPascalSource.pas"/> 293 <Caret Line="479" Column="18" TopLine="470"/> 294 294 </Position26> 295 295 <Position27> 296 <Filename Value=" Analyze\UPascalParser.pas"/>297 <Caret Line=" 97" Column="3" TopLine="84"/>296 <Filename Value="UPascalSource.pas"/> 297 <Caret Line="481" Column="1" TopLine="470"/> 298 298 </Position27> 299 299 <Position28> 300 <Filename Value=" Analyze\UPascalParser.pas"/>301 <Caret Line=" 721" Column="69" TopLine="708"/>300 <Filename Value="UPascalSource.pas"/> 301 <Caret Line="482" Column="1" TopLine="470"/> 302 302 </Position28> 303 303 <Position29> 304 <Filename Value=" Analyze\UPascalParser.pas"/>305 <Caret Line=" 782" Column="62" TopLine="770"/>304 <Filename Value="UPascalSource.pas"/> 305 <Caret Line="484" Column="1" TopLine="470"/> 306 306 </Position29> 307 307 <Position30> 308 <Filename Value=" Analyze\UPascalParser.pas"/>309 <Caret Line=" 829" Column="64" TopLine="816"/>308 <Filename Value="UPascalSource.pas"/> 309 <Caret Line="483" Column="3" TopLine="470"/> 310 310 </Position30> 311 311 </JumpHistory> … … 347 347 </CompilerOptions> 348 348 <Debugging> 349 <BreakPoints Count=" 2">349 <BreakPoints Count="1"> 350 350 <Item1> 351 351 <Source Value="Analyze\UPascalParser.pas"/> 352 <Line Value=" 409"/>352 <Line Value="392"/> 353 353 </Item1> 354 <Item2>355 <Source Value="Analyze\UPascalParser.pas"/>356 <Line Value="275"/>357 </Item2>358 354 </BreakPoints> 359 355 <Exceptions Count="3"> -
branches/DelphiToC/UPascalCompiler.pas
r36 r39 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls,UPascalSource, UCodeProducer, UPascalParser, UAssemblerSource,9 Dialogs, UPascalSource, UCodeProducer, UPascalParser, UAssemblerSource, 10 10 UCSource; 11 11 -
branches/DelphiToC/UPascalSource.pas
r38 r39 7 7 uses 8 8 SysUtils, Variants, Classes, Graphics, Controls, Forms, 9 Dialogs, StdCtrls,Contnrs;9 Dialogs, Contnrs; 10 10 11 11 type … … 200 200 end; 201 201 202 { TExpression } 203 202 204 TExpression = class 203 205 CommonBlock: TCommonBlock; … … 211 213 constructor Create; 212 214 destructor Destroy; override; 215 procedure Assign(Source: TExpression); 213 216 end; 214 217 … … 310 313 311 314 destructor TConstantList.Destroy; 312 var 313 I: Integer; 314 begin 315 for I := 0 to Count - 1 do 316 TConstant(Items[I]).Free; 315 begin 317 316 inherited; 318 317 end; … … 394 393 395 394 destructor TTypeList.Destroy; 396 var 397 I: Integer; 398 begin 399 for I := 0 to Count - 1 do 400 TType(Items[I]).Free; 395 begin 401 396 inherited; 402 397 end; … … 430 425 while (I < Count) and (TVariable(Items[I]).Name <> Name) do Inc(I); 431 426 if I < Count then Result := TVariable(Items[I]) else begin 432 if Assigned(Parent.Parent) then Result := Parent.Parent.Variables.Search(Name) 433 else begin 434 Result := nil; 435 end; 427 if Assigned(Parent.Parent) then 428 Result := Parent.Parent.Variables.Search(Name) 429 else Result := nil; 436 430 end; 437 431 end; … … 473 467 SubItems := TExpressionList.Create; 474 468 SubItems.Count := 2; 469 SubItems.OwnsObjects := False; 475 470 end; 476 471 … … 479 474 SubItems.Free; 480 475 inherited; 476 end; 477 478 procedure TExpression.Assign(Source: TExpression); 479 begin 480 CommonBlock := Source.CommonBlock; 481 NodeType := Source.NodeType; 482 Method := Source.Method; 483 Value := Source.Value; 484 Associated := Source.Associated; 485 OperatorName := Source.OperatorName; 486 Variable := Source.Variable; 487 SubItems.Assign(Source.SubItems); 481 488 end; 482 489 … … 503 510 504 511 destructor TExpressionList.Destroy; 505 var 506 I: Integer; 507 begin 508 for I := 0 to Count - 1 do 509 TExpression(Items[I]).Free; 512 begin 510 513 inherited; 511 514 end; … … 514 517 515 518 destructor TParameterList.Destroy; 516 var 517 I: Integer; 518 begin 519 for I := 0 to Count - 1 do 520 TParameter(Items[I]).Free; 519 begin 521 520 inherited; 522 521 end;
Note:
See TracChangeset
for help on using the changeset viewer.