Minor changes to allow for easy registering of ScriptMethodInfoFunction
This commit is contained in:
parent
947904f097
commit
a2c6943c3a
|
@ -10,7 +10,7 @@ using Upsilon.Text;
|
||||||
|
|
||||||
namespace Upsilon.BaseTypes.ScriptFunction
|
namespace Upsilon.BaseTypes.ScriptFunction
|
||||||
{
|
{
|
||||||
internal class ScriptMethodInfoFunction : ScriptFunction
|
public class ScriptMethodInfoFunction : ScriptFunction
|
||||||
{
|
{
|
||||||
public ScriptMethodInfoFunction(UserDataMethod method, object o, bool directTypeManipulation,
|
public ScriptMethodInfoFunction(UserDataMethod method, object o, bool directTypeManipulation,
|
||||||
bool passScriptReference = false, bool passScopeReference = false)
|
bool passScriptReference = false, bool passScopeReference = false)
|
||||||
|
|
|
@ -365,7 +365,7 @@ namespace Upsilon.Binder
|
||||||
{
|
{
|
||||||
return new UserDataVariableSymbol(fullStopIndexExpression.Index, boundDef, true, parent);
|
return new UserDataVariableSymbol(fullStopIndexExpression.Index, boundDef, true, parent);
|
||||||
}
|
}
|
||||||
diagnostics?.LogWarning($"Can't resolve type '{bDefProperty.ToString()}'", fullStopIndexExpression.Span);
|
diagnostics?.LogWarning($"Can't resolve type '{bDefProperty.Type}'", fullStopIndexExpression.Span);
|
||||||
return new VariableSymbol(fullStopIndexExpression.Index, Type.Unknown, true);
|
return new VariableSymbol(fullStopIndexExpression.Index, Type.Unknown, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -624,12 +624,12 @@ namespace Upsilon.Binder
|
||||||
if (e.NextElseIfStatement != null)
|
if (e.NextElseIfStatement != null)
|
||||||
{
|
{
|
||||||
var nextElseIf = BindIfStatement(e.NextElseIfStatement);
|
var nextElseIf = BindIfStatement(e.NextElseIfStatement);
|
||||||
return new BoundIfStatement((BoundExpressionStatement) condition, (BoundBlockStatement) block,
|
return new BoundIfStatement(condition, (BoundBlockStatement) block,
|
||||||
(BoundIfStatement) nextElseIf, e.Span);
|
(BoundIfStatement) nextElseIf, e.Span);
|
||||||
}
|
}
|
||||||
if (e.ElseStatement == null)
|
if (e.ElseStatement == null)
|
||||||
{
|
{
|
||||||
return new BoundIfStatement((BoundExpressionStatement) condition, (BoundBlockStatement) block, e.Span);
|
return new BoundIfStatement(condition, (BoundBlockStatement) block, e.Span);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -638,7 +638,7 @@ namespace Upsilon.Binder
|
||||||
var elseStatement = new BoundElseStatement((BoundBlockStatement) elseBlock, e.Span);
|
var elseStatement = new BoundElseStatement((BoundBlockStatement) elseBlock, e.Span);
|
||||||
Scope = Scope.ParentScope;
|
Scope = Scope.ParentScope;
|
||||||
|
|
||||||
return new BoundIfStatement((BoundExpressionStatement) condition, (BoundBlockStatement) block,
|
return new BoundIfStatement(condition, (BoundBlockStatement) block,
|
||||||
elseStatement, e.Span);
|
elseStatement, e.Span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,13 @@ namespace Upsilon.StandardLibraries
|
||||||
|
|
||||||
public static void RegisterStaticVariable(string name, object value)
|
public static void RegisterStaticVariable(string name, object value)
|
||||||
{
|
{
|
||||||
|
if (value is ScriptType scriptType)
|
||||||
|
{
|
||||||
|
var symbol = new VariableSymbol(name, scriptType.Type, true);
|
||||||
|
BoundScope.AssignToNearest(symbol);
|
||||||
|
Scope.AssignToNearest(symbol, scriptType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
var luaVariable = value.ToScriptType();
|
var luaVariable = value.ToScriptType();
|
||||||
var ubDef = BoundTypeHandler.GetTypeDefinition(value.GetType());
|
var ubDef = BoundTypeHandler.GetTypeDefinition(value.GetType());
|
||||||
VariableSymbol varSymbol = null;
|
VariableSymbol varSymbol = null;
|
||||||
|
|
Loading…
Reference in New Issue