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/Source3.pas

    r97 r98  
    66
    77type
     8  TBaseType = (btBoolean, btInteger, btChar, btShortString, btArray);
     9
    810  TType = record
    911    Name: string;
     12    BaseType: TBaseType;
    1013  end;
    1114  PType = ^TType;
     
    2326    Name: string;
    2427    DataType: PType;
     28    case Integer of
     29      0: (ValueChar: Char);
     30      1: (ValueInteger: Integer);
     31      2: (ValueString: ShortString);
     32      3: (ValueBoolean: Boolean);
    2533  end;
    2634  PVariable = ^TVariable;
     
    3341    function GetByName(Name: string): PVariable;
    3442  end;
     43
     44  TConstant = record
     45    Name: string;
     46    DataType: PType;
     47    case Integer of
     48      0: (ValueChar: Char);
     49      1: (ValueInteger: Integer);
     50      2: (ValueString: ShortString);
     51      3: (ValueBoolean: Boolean);
     52  end;
     53  PConstant = ^TConstant;
    3554
    3655  TFunctionParameter = record
     
    5978      3: (Assignment: TAssignment);
    6079      4: (Execution: TExecution);
    61     end;
    6280 } end;
    6381  PCommand = ^TCommand;
     
    98116    ReturnType: PType;
    99117    BeginEnd: TBeginEnd;
     118    Variables: TVariables;
    100119  end;
    101120  PFunction = ^TFunction;
     
    131150function VariableCreate(Name: string; DataType: PType): TVariable;
    132151function FunctionCreate(Name: string; DataType: PType): TFunction;
    133 function TypeCreate(Name: string): TType;
     152function TypeCreate(Name: string; BaseType: TBaseType): TType;
    134153function FunctionParameterCreate(Name: string; DataType: PType): TFunctionParameter;
    135154
     
    149168end;
    150169
    151 function TypeCreate(Name: string): TType;
    152 begin
    153   Result.Name := Name;
     170function TypeCreate(Name: string; BaseType:TBaseType): TType;
     171begin
     172  Result.Name := Name;
     173  Result.BaseType := BaseType;
    154174end;
    155175
Note: See TracChangeset for help on using the changeset viewer.