Changeset 26 for trunk/Compiler/Analyze
- Timestamp:
- Dec 8, 2010, 10:00:30 AM (14 years ago)
- Location:
- trunk/Compiler/Analyze
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/Analyze/UAnalyzer.pas
r25 r26 8 8 uses 9 9 SysUtils, Variants, Classes, Contnrs, 10 Dialogs, USourceCode, FileUtil ;10 Dialogs, USourceCode, FileUtil, SpecializedObjectList; 11 11 12 12 type … … 82 82 83 83 // TListAnalyzer = TGObjectList<Integer, TAnalyzer> 84 {$DEFINE TGObjectListIndex := Integer} 85 {$DEFINE TGObjectListItem := TAnalyzer} 86 {$DEFINE TGObjectListList := TObjectListAnalyzer} 87 {$DEFINE TGObjectList := TListAnalyzer} 88 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareAnalyzer} 89 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterAnalyzer} 90 {$DEFINE INTERFACE} 91 {$I 'GenericObjectList.inc'} 84 TListAnalyzer = class(TListObject); 92 85 93 86 resourcestring … … 95 88 96 89 implementation 97 98 {$DEFINE IMPLEMENTATION_USES}99 {$I 'GenericObjectList.inc'}100 101 // TListAnalyzer = TGObjectList<Integer, TAnalyzer>102 {$DEFINE TGObjectListIndex := Integer}103 {$DEFINE TGObjectListItem := TAnalyzer}104 {$DEFINE TGObjectListList := TObjectListAnalyzer}105 {$DEFINE TGObjectList := TListAnalyzer}106 {$DEFINE TGObjectListSortCompare := TObjectListSortCompareAnalyzer}107 {$DEFINE TGObjectListStringConverter := TObjectListStringConverterAnalyzer}108 {$DEFINE IMPLEMENTATION}109 {$I 'GenericObjectList.inc'}110 90 111 91 { TAnalyzer } -
trunk/Compiler/Analyze/UAnalyzerPascal.pas
r24 r26 156 156 I := 1; 157 157 while (I < Expressions.Count - 1) do begin 158 if not Expressions[I].Associated and159 ( Expressions[I].OperatorName = Operators[II]) then158 if not TExpression(Expressions[I]).Associated and 159 (TExpression(Expressions[I]).OperatorName = Operators[II]) then 160 160 begin 161 Expressions[I].Associated := True;162 Expressions[I - 1].SubItems.Last := Expressions[I];163 Expressions[I + 1].SubItems.First := Expressions[I];161 TExpression(Expressions[I]).Associated := True; 162 TExpression(Expressions[I - 1]).SubItems.Last := Expressions[I]; 163 TExpression(Expressions[I + 1]).SubItems.First := Expressions[I]; 164 164 Expressions.Delete(I); 165 165 end else Inc(I); 166 166 end; 167 167 end; 168 if Assigned( Expressions.First.SubItems.Last) then169 Assign( Expressions.First.SubItems.Last);170 Expressions.First.SubItems.Last := nil;168 if Assigned(TExpression(Expressions.First).SubItems.Last) then 169 Assign(TExpression(TExpression(Expressions.First).SubItems.Last)); 170 TExpression(Expressions.First).SubItems.Last := nil; 171 171 //ShowMessage(IntToStr(Expressions.Count)); 172 172 if Expressions.Count > 1 then 173 Expressions[1].SubItems.First := nil;173 TExpression(Expressions[1]).SubItems.First := nil; 174 174 end; 175 175 finally … … 191 191 ParseExpression(NewExpression); 192 192 193 Expressions.Last.SubItems.Last := NewExpression;194 with Expressions.Items[Expressions.Add(TExpression.Create)]do193 TExpression(Expressions.Last).SubItems.Last := NewExpression; 194 with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do 195 195 begin 196 196 CommonBlock := SourceCode.CommonBlock; … … 207 207 if IsOperator(NextToken) then begin 208 208 // Operator 209 Expressions.Last.OperatorName := ReadToken;210 Expressions.Last.NodeType := ntOperator;209 TExpression(Expressions.Last).OperatorName := ReadToken; 210 TExpression(Expressions.Last).NodeType := ntOperator; 211 211 Result := True; 212 212 end else Result := False; … … 320 320 end; 321 321 if Assigned(NewExpression) then begin 322 Expressions.Last.SubItems.Last := NewExpression;322 TExpression(Expressions.Last).SubItems.Last := NewExpression; 323 323 with Expressions.Items[Expressions.Add(TExpression.Create)] do 324 324 begin … … 672 672 if UseType is TTypeRecord then begin 673 673 UseFunction := TTypeRecord(UseType).CommonBlock.Functions.Search(UseName); 674 if not Assigned(UseFunction) then begin 675 ErrorMessage(SFunctionNotDeclared, [UseName]); 676 Exit; 677 end; 678 end else 679 if UseType is TTypeClass then begin 680 UseFunction := TTypeClass(UseType).CommonBlock.Functions.Search(UseName); 674 681 if not Assigned(UseFunction) then begin 675 682 ErrorMessage(SFunctionNotDeclared, [UseName]); … … 880 887 with Call do begin 881 888 ParameterExpression.Add(TExpression.Create); 882 ParameterExpression.Last.CommonBlock := SourceCode;883 ParseExpression( ParameterExpression.Last);889 TExpression(ParameterExpression.Last).CommonBlock := SourceCode; 890 ParseExpression(TExpression(ParameterExpression.Last)); 884 891 end; 885 892 Expect(')'); … … 1246 1253 ): Boolean; 1247 1254 var 1255 Visibility: TTypeVisibility; 1256 SectionType: TCommonBlockSection; 1248 1257 NewType2: TType; 1249 1258 TempType: TType; … … 1251 1260 if NextToken = 'class' then begin 1252 1261 Expect('class'); 1262 SectionType := cbsVariable; 1263 Visibility := tvPublic; 1253 1264 TempType := NewType; 1254 1265 NewType := TTypeClass.Create; 1255 1266 NewType.Assign(TempType); 1256 1267 TempType.Free; 1257 if NextToken <> ';' then begin 1258 while (NextToken <> 'end') and (NextTokenType <> ttEndOfFile) do 1259 begin 1260 if ParseType(NewType.Parent, NewType2, True, ':') then begin 1261 NewType2.Parent := NewType.Parent; 1262 TTypeClass(NewType).Items.Add(NewType2); 1263 end; 1264 Expect(';'); 1265 end; 1266 Expect('end'); 1267 end; 1268 TTypeClass(NewType).CommonBlock.Parent := NewType.Parent.Parent; 1269 while (NextToken <> 'end') and (NextTokenType <> ttEndOfFile) do begin 1270 // Visibility sections 1271 if NextToken = 'public' then begin 1272 Expect('public'); 1273 Visibility := tvPublic; 1274 end else 1275 if NextToken = 'private' then begin 1276 Expect('private'); 1277 Visibility := tvPrivate; 1278 end else 1279 if NextToken = 'published' then begin 1280 Expect('published'); 1281 Visibility := tvPublished; 1282 end else 1283 if NextToken = 'protected' then begin 1284 Expect('protected'); 1285 Visibility := tvProtected; 1286 end else 1287 1288 // Definition sections 1289 if NextToken = 'var' then begin 1290 Expect('var'); 1291 SectionType := cbsVariable; 1292 end else 1293 if NextToken = 'const' then begin 1294 Expect('const'); 1295 SectionType := cbsConstant; 1296 end else 1297 if NextToken = 'type' then begin 1298 Expect('type'); 1299 SectionType := cbsType; 1300 end; 1301 1302 if NextToken = 'procedure' then 1303 ParseFunction(TTypeClass(NewType).CommonBlock.Functions, True) 1304 else if NextToken = 'function' then 1305 ParseFunction(TTypeClass(NewType).CommonBlock.Functions, True) 1306 else 1307 if SectionType = cbsConstant then begin 1308 ParseConstant(TTypeClass(NewType).CommonBlock.Constants, True) 1309 end else 1310 if SectionType = cbsVariable then begin 1311 ParseVariable(TTypeClass(NewType).CommonBlock.Variables, True); 1312 end else 1313 if SectionType = cbsType then 1314 with TTypeClass(NewType).CommonBlock do begin 1315 if ParseType(Types, NewType2, True, '=') then begin 1316 Types.Add(NewType2); 1317 NewType2.Parent := Types; 1318 end; 1319 end; 1320 end; 1321 Expect('end'); 1268 1322 Result := True; 1269 1323 end else Result := False;
Note:
See TracChangeset
for help on using the changeset viewer.