-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from WattleScript/feat-field-info
Improve field info of classes&mixins
- Loading branch information
Showing
11 changed files
with
134 additions
and
88 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
30 changes: 30 additions & 0 deletions
30
src/WattleScript.Interpreter/DataTypes/WattleMembersInfo.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,30 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace WattleScript.Interpreter | ||
{ | ||
public sealed class WattleMembersInfo | ||
{ | ||
public IReadOnlyDictionary<string, MemberModifierFlags> Modifiers => i_Modifiers; | ||
|
||
internal readonly Dictionary<string, MemberModifierFlags> i_Modifiers = new Dictionary<string, MemberModifierFlags>(); | ||
|
||
public bool MemberHasModifier(string memberName, MemberModifierFlags modifier) | ||
{ | ||
return MemberHasModifier(DynValue.NewString(memberName), modifier); | ||
} | ||
|
||
public bool MemberHasModifier(DynValue memberName, MemberModifierFlags modifier) | ||
{ | ||
if (memberName.Type != DataType.String) return false; | ||
return i_Modifiers.TryGetValue(memberName.String, out MemberModifierFlags flags) && flags.HasFlag(modifier); | ||
} | ||
|
||
internal void Merge(WattleMembersInfo parent) | ||
{ | ||
parent.i_Modifiers.ToList().ForEach(x => i_Modifiers[x.Key] = x.Value); | ||
} | ||
|
||
internal WattleMembersInfo() { } | ||
} | ||
} |
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
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