Changeset 9


Ignore:
Timestamp:
May 2, 2014, 3:39:44 PM (10 years ago)
Author:
chronos
Message:
  • Modified: Different "depends on" evalution.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UKConfig.pas

    r8 r9  
    2323  TObjectMoves = array of TObjectMove;
    2424
     25  TExpOperator = (eoAnd, eoOr);
     26
     27  { TExpression }
     28
     29  TExpression = class
     30    ExpOperator: TExpOperator;
     31    Items: TObjectList; // TList<TExpression>
     32    constructor Create;
     33    destructor Destroy; override;
     34  end;
     35
     36  TExpressionVar = class
     37    Name: string;
     38    Negative: Boolean;
     39  end;
     40
    2541  { TMenuNode }
    2642
    2743  TMenuNode = class
     44    Index: Integer;
    2845    ID: string;
    2946    Name: string;
     
    6683    Arch: string;
    6784    FOnLog: TOnLogEvent;
     85    IndexCounter: Integer;
    6886    function GetTopCondition: string;
    6987    procedure Log(Text: string);
     
    89107implementation
    90108
     109{ TExpression }
     110
     111constructor TExpression.Create;
     112begin
     113  Items := TObjectList.Create;
     114end;
     115
     116destructor TExpression.Destroy;
     117begin
     118  Items.Free;
     119  inherited Destroy;
     120end;
     121
    91122{ TMenuNode }
    92123
     
    150181  with List do begin
    151182    Clear;
     183    Add('Index: ' + IntToStr(Index));
    152184    Add('ID: ' + ID);
    153185    Add('Name: ' + Name);
     
    199231  Index: Integer;
    200232  P: TMenuNode;
    201 begin
    202   if ID = 'EXT4_FS' then
     233  LatestNode: TMenuNode;
     234begin
     235  if ID = 'PARAVIRT_DEBUG' then
    203236    Name := Name + '$';
    204237  NewParent := Parent;
     
    212245    end;
    213246  end;}
    214   if Depends.Count > 0 then begin
    215     Index := Lookup.IndexOf(Depends[0]);
     247  I := 0;
     248  LatestNode := NewParent;
     249  while I < Depends.Count do begin
     250    Index := Lookup.IndexOf(Depends[I]);
    216251    if Index <> -1 then Node := TMenuNode(Lookup.Objects[Index])
    217252      else Node := nil;
    218     if Assigned(Node) and (NewParent <> Node) and (Node.HaveUpperNode(NewParent)) then begin
    219       NewParent := Node;
     253    if Assigned(Node) and (NewParent <> Node) and (Node.HaveUpperNode(NewParent)) and
     254      (Node.Index > LatestNode.Index) then begin
     255      LatestNode := Node;
    220256    end;
    221   end;
     257    Inc(I);
     258  end;
     259  NewParent := LatestNode;
     260
    222261  if NewParent <> Parent then begin
    223262    NewMove.Source := Self;
     
    436475        Parameter := GetNextToken(Line);
    437476        if Parameter = 'on' then begin
    438           Parameter := GetNextToken(Line);
    439           if Copy(Parameter, 1, 1) = '!' then Delete(Parameter, 1, 1);
    440477          if not Assigned(NewItem) then raise Exception.Create('Item not defined. ' + GetLog);
    441           NewItem.Depends.Add(Parameter);
     478          // Just try to load symbol list. Do not parse expression
     479          while Trim(Line) <> '' do begin
     480            Parameter := GetNextToken(Line);
     481            if Copy(Parameter, 1, 1) = '!' then Delete(Parameter, 1, 1);
     482            if Copy(Parameter, 1, 1) = '(' then Delete(Parameter, 1, 1);
     483            if Copy(Parameter, Length(Parameter), 1) = ')' then Delete(Parameter, Length(Parameter), 1);
     484            Parameter := Trim(Parameter);
     485            if (Parameter <> '&&') and (Parameter <> '||') then
     486              NewItem.Depends.Add(Parameter);
     487          end;
    442488        end;
    443489      end else
     
    470516        NewItem.ID := Parameter;
    471517        NewItem.Condition := GetTopCondition;
     518        NewItem.Index := IndexCounter;
     519        Inc(IndexCounter);
    472520        CurrentMenu.Items.Add(NewItem);
    473521        if Command = 'menuconfig' then NewItem.MenuConfig := True;
     
    479527        NewItem.Name := Parameter;
    480528        NewItem.Condition := GetTopCondition;
     529        NewItem.Index := IndexCounter;
     530        Inc(IndexCounter);
    481531        NewItem.ValueType := vtComment;
    482532        CurrentMenu.Items.Add(NewItem);
     
    498548        NewMenu.Parent := CurrentMenu;
    499549        NewMenu.Condition := GetTopCondition;
     550        NewMenu.Index := IndexCounter;
     551        Inc(IndexCounter);
    500552        ConditionStack.AddObject('', nil);
    501553        NewItem := NewMenu;
     
    563615  TopNode.Name := 'Root';
    564616  CurrentMenu := TopNode;
     617  IndexCounter := 1;
    565618  ParseFile(BaseDir + DirectorySeparator + 'Kconfig');
    566619end;
Note: See TracChangeset for help on using the changeset viewer.