Skip to content

Made SpecialValue even more special. ... #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public Expression(String text, ExecutionContext context)

public object GetValue()
{
return GetValueOfTerm(rootTerm);
Object value = GetValueOfTerm(rootTerm);
if (value is SpecialValue)
value = ((SpecialValue)value).Value;

return value;
}

public object GetValueOfTerm(Term term)
Expand Down Expand Up @@ -248,6 +252,14 @@ private object TryProcessStructure(Term input)
output = ((SpecialValue)baseTermValue).GetSuffix(suffixTerm.Text.ToUpper());
if (output != null) return output;

// Check if the SpecialValues projection is another SpesialValue that possible supports the suffux.
if (baseTermValue != ((SpecialValue)baseTermValue).Value && ((SpecialValue)baseTermValue).Value is SpecialValue)
{
baseTermValue = ((SpecialValue)baseTermValue).Value;
output = ((SpecialValue)baseTermValue).GetSuffix(suffixTerm.Text.ToUpper());
if (output != null) return output;
}

throw new kOSException("Suffix '" + suffixTerm.Text + "' not found on object", executionContext);
}
else
Expand Down
5 changes: 5 additions & 0 deletions SpecialValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace kOS
{
public class SpecialValue
{
public virtual Object Value
{
get { return this; }
}

public virtual bool SetSuffix(String suffixName, object value)
{
return false;
Expand Down