Ignore:
Timestamp:
Dec 8, 2010, 10:00:30 AM (13 years ago)
Author:
george
Message:
  • Removed: Generic template usage form project code. Replaced by TListObject descendants.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Analyze/UAnalyzerPascal.pas

    r24 r26  
    156156        I := 1;
    157157        while (I < Expressions.Count - 1) do begin
    158           if not Expressions[I].Associated and
    159             (Expressions[I].OperatorName = Operators[II]) then
     158          if not TExpression(Expressions[I]).Associated and
     159            (TExpression(Expressions[I]).OperatorName = Operators[II]) then
    160160          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];
    164164            Expressions.Delete(I);
    165165          end else Inc(I);
    166166        end;
    167167      end;
    168       if Assigned(Expressions.First.SubItems.Last) then
    169         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;
    171171      //ShowMessage(IntToStr(Expressions.Count));
    172172      if Expressions.Count > 1 then
    173         Expressions[1].SubItems.First := nil;
     173        TExpression(Expressions[1]).SubItems.First := nil;
    174174    end;
    175175  finally
     
    191191    ParseExpression(NewExpression);
    192192
    193     Expressions.Last.SubItems.Last := NewExpression;
    194     with Expressions.Items[Expressions.Add(TExpression.Create)] do
     193    TExpression(Expressions.Last).SubItems.Last := NewExpression;
     194    with TExpression(Expressions.Items[Expressions.Add(TExpression.Create)]) do
    195195    begin
    196196      CommonBlock := SourceCode.CommonBlock;
     
    207207  if IsOperator(NextToken) then begin
    208208    // Operator
    209     Expressions.Last.OperatorName := ReadToken;
    210     Expressions.Last.NodeType := ntOperator;
     209    TExpression(Expressions.Last).OperatorName := ReadToken;
     210    TExpression(Expressions.Last).NodeType := ntOperator;
    211211    Result := True;
    212212  end else Result := False;
     
    320320    end;
    321321    if Assigned(NewExpression) then begin
    322       Expressions.Last.SubItems.Last := NewExpression;
     322      TExpression(Expressions.Last).SubItems.Last := NewExpression;
    323323      with Expressions.Items[Expressions.Add(TExpression.Create)] do
    324324      begin
     
    672672      if UseType is TTypeRecord then begin
    673673        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);
    674681        if not Assigned(UseFunction) then begin
    675682          ErrorMessage(SFunctionNotDeclared, [UseName]);
     
    880887        with Call do begin
    881888          ParameterExpression.Add(TExpression.Create);
    882           ParameterExpression.Last.CommonBlock := SourceCode;
    883           ParseExpression(ParameterExpression.Last);
     889          TExpression(ParameterExpression.Last).CommonBlock := SourceCode;
     890          ParseExpression(TExpression(ParameterExpression.Last));
    884891        end;
    885892        Expect(')');
     
    12461253  ): Boolean;
    12471254var
     1255  Visibility: TTypeVisibility;
     1256  SectionType: TCommonBlockSection;
    12481257  NewType2: TType;
    12491258  TempType: TType;
     
    12511260  if NextToken = 'class' then begin
    12521261    Expect('class');
     1262    SectionType := cbsVariable;
     1263    Visibility := tvPublic;
    12531264    TempType := NewType;
    12541265    NewType := TTypeClass.Create;
    12551266    NewType.Assign(TempType);
    12561267    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');
    12681322    Result := True;
    12691323  end else Result := False;
Note: See TracChangeset for help on using the changeset viewer.