Changeset 212 for branches/interpreter2/USource.pas
- Timestamp:
- Apr 22, 2020, 12:04:22 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/USource.pas
r211 r212 12 12 TFunctions = class; 13 13 TBeginEnd = class; 14 TBlock = class; 14 15 15 16 TDataType = (dtNone, dtString, dtBoolean, dtInteger, dtFloat, dtColor, … … 129 130 Name: string; 130 131 TypeRef: TType; 132 Internal: Boolean; 131 133 procedure GetValue(Index: Integer; out Value); override; 132 134 function GetField(Index: Integer): TField; override; … … 183 185 Params: TFunctionParameters; 184 186 ResultType: TType; 185 BeginEnd: TBeginEnd; 187 Block: TBlock; 188 ParentType: TType; 186 189 procedure GetValue(Index: Integer; out Value); override; 187 190 function GetField(Index: Integer): TField; override; … … 194 197 195 198 TFunctions = class(TSourceNodes) 199 ParentType: TType; 196 200 function SearchByName(Name: string): TFunction; 197 201 function AddNew(Name: string): TFunction; … … 253 257 public 254 258 TypeRef: TType; 259 FunctionRef: TFunction; 255 260 Operation: TExpressionOperator; 256 261 Items: TExpressions; 262 function GetFunctionName: string; 257 263 procedure GetValue(Index: Integer; out Value); override; 258 264 function GetField(Index: Integer): TField; override; … … 839 845 procedure TFunction.GetValue(Index: Integer; out Value); 840 846 begin 841 if Index = 0 then TB eginEnd(Value) := BeginEnd847 if Index = 0 then TBlock(Value) := Block 842 848 else if Index = 1 then TFunctionParameters(Value) := Params 843 849 else if Index = 2 then TType(Value) := ResultType … … 862 868 procedure TFunction.SetValue(Index: Integer; var Value); 863 869 begin 864 if Index = 0 then B eginEnd := TBeginEnd(Value)870 if Index = 0 then Block := TBlock(Value) 865 871 else if Index = 1 then Params := TFunctionParameters(Value) 866 872 else if Index = 2 then ResultType := TType(Value) … … 872 878 begin 873 879 Params := TFunctionParameters.Create; 874 B eginEnd := TBeginEnd.Create;880 Block := TBlock.Create; 875 881 end; 876 882 877 883 destructor TFunction.Destroy; 878 884 begin 879 B eginEnd.Free;885 Block.Free; 880 886 Params.Free; 881 887 inherited Destroy; … … 910 916 begin 911 917 Functions := TFunctions.Create; 918 Functions.ParentType := Self; 912 919 end; 913 920 … … 950 957 end; 951 958 959 function TExpressionOperation.GetFunctionName: string; 960 begin 961 if Operation = eoAdd then Result := '_Add' 962 else if Operation = eoSub then Result := '_Sub' 963 else if Operation = eoEqual then Result := '_Equal' 964 else if Operation = eoNotEqual then Result := '_NotEqual' 965 else raise Exception.Create('Unsupported operation type.'); 966 end; 967 952 968 function TExpressionOperation.GetFieldsCount: Integer; 953 969 begin … … 1159 1175 Result := TFunction.Create; 1160 1176 Result.Name := Name; 1177 Result.ParentType := ParentType; 1161 1178 Add(Result); 1162 1179 end; … … 1242 1259 Result := Types.SearchByName(Name); 1243 1260 if not Assigned(Result) and Assigned(ParentBlock) then 1244 Result := ParentBlock. Types.SearchByName(Name);1261 Result := ParentBlock.GetType(Name); 1245 1262 end; 1246 1263 … … 1249 1266 Result := Constants.SearchByName(Name); 1250 1267 if not Assigned(Result) and Assigned(ParentBlock) then 1251 Result := ParentBlock. Constants.SearchByName(Name);1268 Result := ParentBlock.GetConstant(Name); 1252 1269 end; 1253 1270 … … 1256 1273 Result := Variables.SearchByName(Name); 1257 1274 if not Assigned(Result) and Assigned(ParentBlock) then 1258 Result := ParentBlock. Variables.SearchByName(Name);1275 Result := ParentBlock.GetVariable(Name); 1259 1276 end; 1260 1277 … … 1263 1280 Result := Functions.SearchByName(Name); 1264 1281 if not Assigned(Result) and Assigned(ParentBlock) then 1265 Result := ParentBlock. Functions.SearchByName(Name);1282 Result := ParentBlock.GetFunction(Name); 1266 1283 end; 1267 1284 … … 1269 1286 begin 1270 1287 Constants := TConstants.Create; 1288 Constants.Parent := Self; 1271 1289 Variables := TVariables.Create; 1290 Variables.Parent := Self; 1272 1291 Functions := TFunctions.Create; 1292 Functions.Parent := Self; 1273 1293 Types := TTypes.Create; 1294 Types.Parent := Self; 1274 1295 BeginEnd := TBeginEnd.Create; 1296 BeginEnd.Parent := Self; 1275 1297 end; 1276 1298
Note:
See TracChangeset
for help on using the changeset viewer.