Work on standard libraries.

- Allows Standard Libraries to work with actual luatypes, to prevent constant back and forth casting
- adds ipairs function, doesn't do anything except maintain compatibility with lua
- several tests
This commit is contained in:
2018-11-24 13:35:40 +01:00
parent 806b3d5689
commit c63df3c941
13 changed files with 88 additions and 42 deletions

View File

@@ -18,7 +18,7 @@ namespace Upsilon.BaseTypes.UserData
var key = index.ToCSharpObject();
if (Dictionary.Contains(key))
{
return Dictionary[key].ToLuaType();
return Dictionary[key].ToScriptType();
}
//TODO: log error
return new ScriptNull();

View File

@@ -32,7 +32,7 @@ namespace Upsilon.BaseTypes.UserData
{
return null;
}
return List[i].ToLuaType();
return List[i].ToScriptType();
}
public void Set(Diagnostics diagnostics, TextSpan span, ScriptType index, ScriptType value)

View File

@@ -30,10 +30,12 @@ namespace Upsilon.BaseTypes.UserData
public bool IsOptional { get; }
}
public string Name { get; }
private List<UserDataMethodPart> MethodParts { get; }
public UserDataMethod(MethodInfo method)
{
Name = method.Name;
var part = new UserDataMethodPart(method);
MethodParts = new List<UserDataMethodPart>()
{

View File

@@ -40,15 +40,15 @@ namespace Upsilon.BaseTypes.UserData
member = member.ToLowerInvariant();
if (Variables.TryGetValue(member, out var info))
{
return (info.GetValue(value).ToLuaType(), false, null);
return (info.GetValue(value).ToScriptType(), false, null);
}
if (Properties.TryGetValue(member, out var property))
{
return (property.GetValue(value).ToLuaType(), false, null);
return (property.GetValue(value).ToScriptType(), false, null);
}
if (Methods.TryGetValue(member, out var method))
{
return (new ScriptMethodInfoFunction(method, value), false, null);
return (new ScriptMethodInfoFunction(method, value, false), false, null);
}
return (null, true, $"Can't find public member '{member}' on type '{Type}'.");
@@ -85,7 +85,7 @@ namespace Upsilon.BaseTypes.UserData
return (new ScriptNull(), true);
}
return (method.Invoke(value, new[] {par1.ToCSharpObject(), par2.ToCSharpObject()}).ToLuaType(), false);
return (method.Invoke(value, new[] {par1.ToCSharpObject(), par2.ToCSharpObject()}).ToScriptType(), false);
}
public (ScriptType Type, bool Failed) UnaryOperator(object value, ScriptType par1, OperatorType op)
{
@@ -95,7 +95,7 @@ namespace Upsilon.BaseTypes.UserData
return (new ScriptNull(), true);
}
return (method.Invoke(value, new[] {par1.ToCSharpObject()}).ToLuaType(), false);
return (method.Invoke(value, new[] {par1.ToCSharpObject()}).ToScriptType(), false);
}
}
}