Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A fresh start at prototyping the new multi-dispatch, after discussion…
…s with TimToady++. Nothing working yet, but this starts us storing the candidates per scope and stubs in some logic for us to go looking for them. Needs a first crack at lists before we can make this work at all, though.
- Loading branch information
Showing
7 changed files
with
116 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
dotnet/runtime/Runtime/MultiDispatch/LexicalCandidateFinder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Rakudo.Metamodel; | ||
using Rakudo.Metamodel.Representations; | ||
|
||
namespace Rakudo.Runtime.MultiDispatch | ||
{ | ||
/// <summary> | ||
/// Finds all candidates that we may dispatch to. | ||
/// </summary> | ||
public static class LexicalCandidateFinder | ||
{ | ||
/// <summary> | ||
/// Locates all matching candidates between the two scopes. | ||
/// </summary> | ||
/// <param name="FromScope"></param> | ||
/// <param name="ToScope"></param> | ||
/// <param name="Name"></param> | ||
/// <returns></returns> | ||
public static List<RakudoCodeRef.Instance> FindCandidates(Context CallerScope, Context ProtoScope, string CandidateHolderName) | ||
{ | ||
var Result = new List<RakudoCodeRef.Instance>(); | ||
Context CurScope = null; | ||
do | ||
{ | ||
// Get the next outer scope, or alternatively start off with the | ||
// caller scope. | ||
CurScope = CurScope == null ? CallerScope : CurScope.Outer; | ||
|
||
// Any candidates here? | ||
|
||
|
||
} while (CurScope != ProtoScope); | ||
return Result; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Rakudo.Metamodel; | ||
using Rakudo.Metamodel.Representations; | ||
|
||
namespace Rakudo.Runtime.MultiDispatch | ||
{ | ||
/// <summary> | ||
/// Very first cut implementation of a multi-dispatcher. Doesn't yet | ||
/// know about subtyping beyond no type being the top type. Yes, this | ||
/// will likely get replaced (or extensively re-done) at some point. | ||
/// </summary> | ||
public static class MultiDispatcher | ||
{ | ||
public static RakudoCodeRef.Instance FindBestCandidate(List<RakudoCodeRef.Instance> Candidates, RakudoObject Capture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters