add small todolist for me
This commit is contained in:
parent
703410b548
commit
47dcc24e1e
|
|
@ -10,6 +10,21 @@ namespace Qrakhen.Qamp.Core.Execution;
|
||||||
|
|
||||||
using Op = OpCode;
|
using Op = OpCode;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Todo:
|
||||||
|
* - Make Digester OOP-ish
|
||||||
|
* - inherit from a base digester that has the continouus stack / reader references as protected information
|
||||||
|
* - one digester for every job area (Loops, Functions, Variables, etc.)
|
||||||
|
* - time is not as essential here as I want to have the executables pre-compiled to OpCodes anyway
|
||||||
|
* - Think of a cleaner way to handle Obj (Pointers specifically)
|
||||||
|
* - Finish runner
|
||||||
|
* - add interpretation for all remaining op codes
|
||||||
|
* - make variable operations faster with optimized inline lambda expressions
|
||||||
|
* - better debugging for the instruction set
|
||||||
|
* - Add classic sqript dialect
|
||||||
|
* - Fix console "IDE"
|
||||||
|
*/
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dynamic Pointer able to point to any object implementing the <see cref="IGetSet{long, TValue}"/> interface.
|
/// Dynamic Pointer able to point to any object implementing the <see cref="IGetSet{long, TValue}"/> interface.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -83,16 +98,18 @@ public class InstructionPtr : Pointer<Instruction>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String? GetString(long offset)
|
public String? GetStringConstant(long offset)
|
||||||
{
|
{
|
||||||
return Segment.Constants[offset].Ptr.Value as String;
|
return Segment.Constants[offset].Ptr.Value as String;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instruction Instruction => Segment.Instructions[Ptr];
|
public Instruction Instruction => Segment.Instructions[Ptr];
|
||||||
|
|
||||||
public static Instruction operator +(InstructionPtr ptr, int value) => ptr.Segment.Instructions[ptr.Ptr + value];
|
public static Instruction operator +(InstructionPtr ptr, int value)
|
||||||
|
=> ptr.Segment.Instructions[ptr.Ptr + value];
|
||||||
|
|
||||||
public static Instruction operator -(InstructionPtr ptr, int value) => ptr.Segment.Instructions[ptr.Ptr - value];
|
public static Instruction operator -(InstructionPtr ptr, int value)
|
||||||
|
=> ptr.Segment.Instructions[ptr.Ptr - value];
|
||||||
|
|
||||||
public static InstructionPtr operator ++(InstructionPtr ptr)
|
public static InstructionPtr operator ++(InstructionPtr ptr)
|
||||||
{
|
{
|
||||||
|
|
@ -203,7 +220,7 @@ public class Runner : IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
case Op.DefineGlobal: {
|
case Op.DefineGlobal: {
|
||||||
string? name = call.Instruction.GetString(call.Instruction.NextDynamic())?.Value;
|
string? name = call.Instruction.GetStringConstant(call.Instruction.NextDynamic())?.Value;
|
||||||
if (string.IsNullOrEmpty(name))
|
if (string.IsNullOrEmpty(name))
|
||||||
throw new ExecutionException($"tried to define global variable with empty name");
|
throw new ExecutionException($"tried to define global variable with empty name");
|
||||||
Globals[name] = Pop();
|
Globals[name] = Pop();
|
||||||
|
|
@ -212,7 +229,7 @@ public class Runner : IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
case Op.SetGlobal: {
|
case Op.SetGlobal: {
|
||||||
string? name = call.Instruction.GetString(call.Instruction.NextDynamic())?.Value;
|
string? name = call.Instruction.GetStringConstant(call.Instruction.NextDynamic())?.Value;
|
||||||
if (string.IsNullOrEmpty(name))
|
if (string.IsNullOrEmpty(name))
|
||||||
throw new ExecutionException($"tried to set global variable with empty name");
|
throw new ExecutionException($"tried to set global variable with empty name");
|
||||||
if (!Globals.Has(name))
|
if (!Globals.Has(name))
|
||||||
|
|
@ -223,7 +240,7 @@ public class Runner : IDisposable
|
||||||
}
|
}
|
||||||
|
|
||||||
case Op.GetGlobal: {
|
case Op.GetGlobal: {
|
||||||
string? name = call.Instruction.GetString(call.Instruction.NextDynamic())?.Value;
|
string? name = call.Instruction.GetStringConstant(call.Instruction.NextDynamic())?.Value;
|
||||||
if (string.IsNullOrEmpty(name))
|
if (string.IsNullOrEmpty(name))
|
||||||
throw new ExecutionException($"tried to set global variable with empty name");
|
throw new ExecutionException($"tried to set global variable with empty name");
|
||||||
if (!Globals.Has(name))
|
if (!Globals.Has(name))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue