Ignore:
Timestamp:
Feb 3, 2017, 10:48:19 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Handling of constant and variables values with different type.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter/Execute3.pas

    r97 r98  
    2121end;
    2222
    23 function ExecuteExpression(Expression: PExpression): Boolean;
     23function ExecuteExpressionBoolean(Expression: PExpression): Boolean;
    2424begin
    2525
     
    2828procedure ExecuteWhileDo(WhileDo: PWhileDo);
    2929begin
    30   if ExecuteExpression(@WhileDo^.Condition) then
     30  while ExecuteExpressionBoolean(@WhileDo^.Condition) do
    3131    ExecuteCommand(@WhileDo^.Command);
    3232end;
     
    3434procedure ExecuteIfThenElse(IfThenElse: PIfThenElse);
    3535begin
    36   if ExecuteExpression(@IfThenElse^.Condition) then
     36  if ExecuteExpressionBoolean(@IfThenElse^.Condition) then
    3737    ExecuteCommand(@IfThenElse^.DoThen)
    3838    else ExecuteCommand(@IfThenElse^.DoElse);
     
    4040
    4141procedure ExecuteExecution(Execution: PExecution);
     42var
     43  I: Integer;
    4244begin
    43   // Set parameters
     45{  Execution^.Func^.Variables.Add(VariableCreate('Result', Execution^.Func^.ReturnType));
     46  for I := 0 to Length(Execution^.Func^.Parameters.Items) - 1 do begin
     47    Execution^.Func^.Variables.Add(VariableCreate(Execution^.Func^.Parameters.Items[I].Name,
     48      Execution^.Func^.Parameters.Items[I].DataType));
     49    case Assignment^.Destination^.DataType^.BaseType of
     50      Execution^.Func^.Variables.Items[Length(Execution^.Func^.Variables.Items) - 1].V
     51    end;
     52  end;
     53}
    4454  ExecuteBeginEnd(@Execution^.Func^.BeginEnd);
    4555end;
     
    4757procedure ExecuteAssignment(Assignment: PAssignment);
    4858begin
    49 
     59  case Assignment^.Destination^.DataType^.BaseType of
     60    btBoolean: Assignment^.Destination.ValueBoolean := ExecuteExpressionBoolean(@Assignment^.Source);
     61    //btChar: Assignment^.Destination.ValueBoolean := ExecuteExpressionChar(@Assignment^.Source);
     62    //btString: Assignment^.Destination.ValueBoolean := ExecuteExpressionString(@Assignment^.Source);
     63    //btInteger: Assignment^.Destination.ValueBoolean := ExecuteExpressionInteger(@Assignment^.Source);
     64  end;
    5065end;
    5166
Note: See TracChangeset for help on using the changeset viewer.