Ignore:
Timestamp:
Aug 9, 2010, 12:48:14 PM (14 years ago)
Author:
george
Message:

Support for function definition with result type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/UPascalSource.pas

    r45 r47  
    5757  end;
    5858
    59   TMethodCall = class(TCommand)
    60     Method: TFunction;
     59  TFunctionCall = class(TCommand)
     60    FunctionRef: TFunction;
    6161  end;
    6262
     
    185185    Name: string;
    186186    ValueType: TType;
    187     Value: TValue;
     187    DefaultValue: TValue;
    188188  end;
    189189
     
    194194  end;
    195195
    196   TParameter = class
    197     Name: string;
    198     ValueType: TType;
    199     DafaultValue: TValue;
     196  TParameter = class(TVariable)
    200197  end;
    201198
     
    241238  TFunction = class(TCommonBlock)
    242239  public
     240    HaveResult: Boolean;
    243241    Parameters: TParameterList;
    244242    ResultType: TType;
     
    439437  I := 0;
    440438  while (I < Count) and (LowerCase(TVariable(Items[I]).Name) <> LowerCase(Name)) do Inc(I);
    441   if I < Count then Result := TVariable(Items[I]) else begin
     439  if I < Count then Result := TVariable(Items[I]) else Result := nil;
     440
     441  if not Assigned(Result) then begin
    442442    if Assigned(Parent.Parent) then
    443443      Result := Parent.Parent.Variables.Search(Name)
     444      else Result := nil;
     445  end;
     446
     447  if not Assigned(Result) then begin
     448    if Assigned(Parent) and (Parent is TFunction) then
     449      Result := TFunction(Parent).Parameters.Search(Name)
     450      else Result := nil;
     451  end;
     452
     453  if not Assigned(Result) then begin
     454    if Assigned(Parent.Parent) and (Parent.Parent is TFunction) then
     455      Result := TFunction(Parent.Parent).Parameters.Search(Name)
    444456      else Result := nil;
    445457  end;
     
    533545begin
    534546  I := 0;
    535   while (I < Count) and (TParameter(Items[I]).Name <> LowerCase(Name)) do Inc(I);
     547  while (I < Count) and (LowerCase(TParameter(Items[I]).Name) <> LowerCase(Name)) do Inc(I);
    536548  if I < Count then Result := TParameter(Items[I])
    537549    else Result := nil;
Note: See TracChangeset for help on using the changeset viewer.