Ignore:
Timestamp:
Nov 5, 2010, 9:36:20 AM (14 years ago)
Author:
george
Message:
  • Fixed: Variable and constant expression.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Compiler/Produce/UProducerPascal.pas

    r2 r5  
    309309function TProducerPascal.GenerateExpression(Expression: TExpression): string;
    310310begin
    311   case Expression.NodeType of
    312     ntConstant: Result := Expression.Value;
    313     ntVariable: Result := Expression.Variable.Name;
    314     ntFunction: Result := Expression.FunctionCall.Name;
    315     ntOperator: begin
    316       Result := GenerateExpression(TExpression(Expression.SubItems.First))
    317         + ' ' + Expression.OperatorName + ' ' +
    318         GenerateExpression(TExpression(Expression.SubItems.Last));
    319     end;
    320     ntNone: ;
     311  if Assigned(Expression) then begin
     312    case Expression.NodeType of
     313      ntConstant: begin
     314        Result := Expression.Constant.Name;
     315      end;
     316      ntValue: begin
     317       if VarType(Expression.Value) = varString then
     318          Result := '''' + Expression.Value + ''''
     319          else Result := Expression.Value;
     320      end;
     321      ntVariable: Result := Expression.Variable.Name;
     322      ntFunction: Result := Expression.FunctionCall.Name;
     323      ntOperator: begin
     324        Result := GenerateExpression(TExpression(Expression.SubItems.First))
     325          + ' ' + Expression.OperatorName + ' ' +
     326          GenerateExpression(TExpression(Expression.SubItems.Last));
     327      end;
     328      ntNone: ;
     329    end;
     330    if Expression.Braces then Result := '(' + Result + ')';
    321331  end;
    322332end;
Note: See TracChangeset for help on using the changeset viewer.