Refactoring
This commit is contained in:
@@ -210,7 +210,6 @@ begin
|
|||||||
FWorkspace.Repaint;
|
FWorkspace.Repaint;
|
||||||
|
|
||||||
FGScope := TAst.CreateScope(nil);
|
FGScope := TAst.CreateScope(nil);
|
||||||
RegisterNativeFunctions(FGScope);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TForm1.CompileAst(const ANode: IAstNode; const AParentScope: IExecutionScope; out ADescriptor: IScopeDescriptor): IAstNode;
|
function TForm1.CompileAst(const ANode: IAstNode; const AParentScope: IExecutionScope; out ADescriptor: IScopeDescriptor): IAstNode;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
T:\Myc\IntfExtract\Win64\Debug\ExtractPascalInterfaces.exe -c -dirs T:\Myc\dirs.txt -fc T:\Myc\Src\Ast\Myc.Ast.*.pas
|
T:\Myc\IntfExtract\Win64\Debug\ExtractPascalInterfaces.exe -c -dirs T:\Myc\dirs.txt -fc T:\Myc\Src\Ast\Myc.Ast*
|
||||||
@@ -62,20 +62,16 @@ type
|
|||||||
function Execute(const RootNode: IAstNode): TDataValue;
|
function Execute(const RootNode: IAstNode): TDataValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Registers native Delphi functions into a scope.
|
|
||||||
procedure RegisterNativeFunctions(const AScope: IExecutionScope);
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
System.TypInfo,
|
System.TypInfo,
|
||||||
System.Generics.Defaults,
|
System.Generics.Defaults,
|
||||||
Myc.Ast, // Added
|
Myc.Ast,
|
||||||
Myc.Data.Keyword,
|
Myc.Data.Keyword,
|
||||||
Myc.Data.Decimal,
|
Myc.Data.Decimal,
|
||||||
Myc.Data.Series,
|
Myc.Data.Series,
|
||||||
Myc.Data.Scalar.JSON;
|
Myc.Data.Scalar.JSON;
|
||||||
// Myc.Ast.Binding.Nodes; // Removed
|
|
||||||
|
|
||||||
// Helper type for TCO via trampolining.
|
// Helper type for TCO via trampolining.
|
||||||
type
|
type
|
||||||
@@ -93,34 +89,6 @@ begin
|
|||||||
Recur := ARecur;
|
Recur := ARecur;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// --- Native Functions Implementation ---
|
|
||||||
|
|
||||||
function NativeCreateRecordSeries(const Args: TArray<TDataValue>): TDataValue;
|
|
||||||
var
|
|
||||||
jsonDef: string;
|
|
||||||
recordDef: IScalarRecordDefinition;
|
|
||||||
series: IRecordSeries;
|
|
||||||
begin
|
|
||||||
if (Length(Args) <> 1) or (Args[0].Kind <> vkText) then
|
|
||||||
raise EArgumentException.Create('CreateRecordSeries requires one string argument.');
|
|
||||||
|
|
||||||
jsonDef := Args[0].AsText;
|
|
||||||
recordDef := TRttiAstHelper.JsonToRecordDefinition(jsonDef);
|
|
||||||
|
|
||||||
if Length(recordDef.Fields) = 0 then
|
|
||||||
raise EArgumentException.Create('Failed to parse record definition from JSON.');
|
|
||||||
|
|
||||||
series := TScalarRecordSeries.Create(recordDef);
|
|
||||||
Result := TDataValue.FromRecordSeries(series);
|
|
||||||
end;
|
|
||||||
|
|
||||||
// --- Registration Procedure ---
|
|
||||||
|
|
||||||
procedure RegisterNativeFunctions(const AScope: IExecutionScope);
|
|
||||||
begin
|
|
||||||
AScope.Define('CreateRecordSeries', TDataValue(NativeCreateRecordSeries));
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TDynamicRecord }
|
{ TDynamicRecord }
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|||||||
@@ -1090,7 +1090,6 @@ end;
|
|||||||
procedure TPrettyPrintVisitor.VisitNop(const Node: INopNode);
|
procedure TPrettyPrintVisitor.VisitNop(const Node: INopNode);
|
||||||
begin
|
begin
|
||||||
// A placeholder node, usually for UI.
|
// A placeholder node, usually for UI.
|
||||||
//TODO Nop soll durch ein spezielles ...-Token repräsentiert werden. Analysiere, ob dies syntaktisch möglich ist. Wenn ja, soll der Parser "inoffiziell" in der Lage sein Nops zu lesen und zu erzeugen.
|
|
||||||
Append('...');
|
Append('...');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user