Pipes refactoring, Fixes in type checker
This commit is contained in:
@@ -411,7 +411,7 @@ begin
|
||||
vkRecordSeries: Result := base.AsRecordSeries.Fields[N.Member.Value];
|
||||
vkScalarRecord: Result := base.AsScalarRecord.Fields[N.Member.Value];
|
||||
vkRecord: Result := base.AsRecord.Fields[N.Member.Value];
|
||||
vkStream: Result := base.AsStream.Series.Fields[N.Member.Value];
|
||||
// vkStream: Result := base.AsStream.Def.Fields[N.Member.Value];
|
||||
else
|
||||
raise EEvaluatorException.Create('Member error');
|
||||
end;
|
||||
@@ -549,7 +549,6 @@ var
|
||||
sources: TArray<IStream>;
|
||||
config: TPipeConfig;
|
||||
inputVal: TDataValue;
|
||||
sourceSeries: IScalarRecordSeries;
|
||||
lambdaFunc: TDataValue.TFunc;
|
||||
|
||||
inputsElements: TArray<IAstNode>;
|
||||
@@ -581,8 +580,7 @@ begin
|
||||
raise EEvaluatorException.Create(Format('Variable "%s" is not a Stream.', [sourceId.Name]));
|
||||
|
||||
sources[i] := inputVal.AsStream;
|
||||
sourceSeries := sources[i].Series;
|
||||
var srcDef := sourceSeries.Def;
|
||||
var srcDef := sources[i].Def;
|
||||
|
||||
// Build Selectors Config
|
||||
SetLength(config[i], Length(selectorsElements));
|
||||
@@ -601,11 +599,18 @@ begin
|
||||
// Compile the transformation function
|
||||
lambdaFunc := Visit(N.Transformation).AsMethod();
|
||||
|
||||
// Allow both stRecord and stRecordSeries (as TypeChecker correctly assigns stRecordSeries for Pipe nodes)
|
||||
if (N.StaticType.Kind <> stRecordSeries) and (N.StaticType.Kind <> stRecord) then
|
||||
raise EEvaluatorException.Create('Pipe requires Type Checking to determine output structure (RecordDefinition).');
|
||||
var outputDef: IScalarRecordDefinition;
|
||||
|
||||
var outputDef := N.StaticType.AsRecord.Definition;
|
||||
case N.StaticType.Kind of
|
||||
stVoid:
|
||||
// This is an endpoint. The lambda returns nothing. So we produce "nothing".
|
||||
outputDef := TScalarRecord.TRegistry.Empty;
|
||||
stRecord, stRecordSeries:
|
||||
// Allow both stRecord and stRecordSeries (as TypeChecker correctly assigns stRecordSeries for Pipe nodes)
|
||||
outputDef := N.StaticType.AsRecord.Definition;
|
||||
else
|
||||
raise EEvaluatorException.Create('Pipe requires Type Checking to determine output structure (RecordDefinition).');
|
||||
end;
|
||||
|
||||
var pipeAdapter: TPipeStream.TPipeLambda :=
|
||||
function(const S: array of ISeries; out R: array of TScalar.TValue): Boolean
|
||||
@@ -630,7 +635,8 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
Result := TPipeStream.Create(config, outputDef, sources, pipeAdapter);
|
||||
//TODO Lookback not evaluated in script!
|
||||
Result := TPipeStream.Create(config, outputDef, sources, pipeAdapter, 1000);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
Reference in New Issue
Block a user