Cleanup.
This commit is contained in:
parent
4d7898f723
commit
3fd8c28230
1 changed files with 15 additions and 17 deletions
|
@ -121,14 +121,13 @@ namespace arookas
|
||||||
// callables
|
// callables
|
||||||
public sunBuiltinSymbol DeclareBuiltin(sunBuiltinDeclaration node)
|
public sunBuiltinSymbol DeclareBuiltin(sunBuiltinDeclaration node)
|
||||||
{
|
{
|
||||||
var symbolInfo = SymbolTable.Callables.FirstOrDefault(f => f.Name == node.Builtin.Value);
|
if (SymbolTable.Callables.Any(i => i.Name == node.Builtin.Value))
|
||||||
if (symbolInfo != null)
|
|
||||||
{
|
{
|
||||||
throw new sunRedeclaredBuiltinException(node);
|
throw new sunRedeclaredBuiltinException(node);
|
||||||
}
|
}
|
||||||
var builtinInfo = new sunBuiltinSymbol(node.Builtin.Value, node.Parameters.ParameterInfo, SymbolTable.Count);
|
var symbol = new sunBuiltinSymbol(node.Builtin.Value, node.Parameters.ParameterInfo, SymbolTable.Count);
|
||||||
SymbolTable.Add(builtinInfo);
|
SymbolTable.Add(symbol);
|
||||||
return builtinInfo;
|
return symbol;
|
||||||
}
|
}
|
||||||
public sunFunctionSymbol DefineFunction(sunFunctionDefinition node)
|
public sunFunctionSymbol DefineFunction(sunFunctionDefinition node)
|
||||||
{
|
{
|
||||||
|
@ -136,18 +135,17 @@ namespace arookas
|
||||||
{
|
{
|
||||||
throw new sunVariadicFunctionException(node);
|
throw new sunVariadicFunctionException(node);
|
||||||
}
|
}
|
||||||
var symbolInfo = SymbolTable.Callables.FirstOrDefault(f => f.Name == node.Function.Value);
|
if (SymbolTable.Callables.Any(i => i.Name == node.Function.Value))
|
||||||
if (symbolInfo != null)
|
|
||||||
{
|
{
|
||||||
throw new sunRedefinedFunctionException(node);
|
throw new sunRedefinedFunctionException(node);
|
||||||
}
|
}
|
||||||
var functionInfo = new sunFunctionSymbol(node.Function.Value, node.Parameters.ParameterInfo, node.Body);
|
var symbol = new sunFunctionSymbol(node.Function.Value, node.Parameters.ParameterInfo, node.Body);
|
||||||
SymbolTable.Add(functionInfo);
|
SymbolTable.Add(symbol);
|
||||||
return functionInfo;
|
return symbol;
|
||||||
}
|
}
|
||||||
public sunCallableSymbol ResolveCallable(sunFunctionCall node)
|
public sunCallableSymbol ResolveCallable(sunFunctionCall node)
|
||||||
{
|
{
|
||||||
var symbol = SymbolTable.Callables.FirstOrDefault(f => f.Name == node.Function.Value);
|
var symbol = SymbolTable.Callables.FirstOrDefault(i => i.Name == node.Function.Value);
|
||||||
if (symbol == null)
|
if (symbol == null)
|
||||||
{
|
{
|
||||||
throw new sunUndefinedFunctionException(node);
|
throw new sunUndefinedFunctionException(node);
|
||||||
|
@ -166,17 +164,17 @@ namespace arookas
|
||||||
|
|
||||||
public sunBuiltinSymbol DeclareSystemBuiltin(string name, bool variadic, params string[] parameters)
|
public sunBuiltinSymbol DeclareSystemBuiltin(string name, bool variadic, params string[] parameters)
|
||||||
{
|
{
|
||||||
var builtinInfo = SymbolTable.Builtins.FirstOrDefault(f => f.Name == name);
|
var symbol = SymbolTable.Builtins.FirstOrDefault(i => i.Name == name);
|
||||||
if (builtinInfo == null)
|
if (symbol == null)
|
||||||
{
|
{
|
||||||
builtinInfo = new sunBuiltinSymbol(name, new sunParameterInfo(parameters, variadic), SymbolTable.Count);
|
symbol = new sunBuiltinSymbol(name, new sunParameterInfo(parameters, variadic), SymbolTable.Count);
|
||||||
SymbolTable.Add(builtinInfo);
|
SymbolTable.Add(symbol);
|
||||||
}
|
}
|
||||||
return builtinInfo;
|
return symbol;
|
||||||
}
|
}
|
||||||
public sunBuiltinSymbol ResolveSystemBuiltin(string name)
|
public sunBuiltinSymbol ResolveSystemBuiltin(string name)
|
||||||
{
|
{
|
||||||
return SymbolTable.Builtins.FirstOrDefault(f => f.Name == name);
|
return SymbolTable.Builtins.FirstOrDefault(i => i.Name == name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// storables
|
// storables
|
||||||
|
|
Loading…
Reference in a new issue