...
This commit is contained in:
@@ -10,8 +10,7 @@ public class ModuleRepository
|
||||
{
|
||||
foreach (var syntaxTree in syntaxTrees)
|
||||
{
|
||||
var moduleName = syntaxTree.Metadata.ModuleName;
|
||||
var module = GetOrCreate(moduleName);
|
||||
var module = GetOrCreate(syntaxTree.Metadata.ModuleName);
|
||||
ProcessSyntaxTree(module, syntaxTree);
|
||||
}
|
||||
}
|
||||
@@ -20,47 +19,7 @@ public class ModuleRepository
|
||||
{
|
||||
foreach (var definition in syntaxTree.Definitions)
|
||||
{
|
||||
switch (definition)
|
||||
{
|
||||
case FuncSyntax funcDef:
|
||||
{
|
||||
var parameters = funcDef.Signature.Parameters
|
||||
.Select(x => new ModuleFunctionParameter(x.Name, x.Type))
|
||||
.ToList();
|
||||
|
||||
module.RegisterFunction(funcDef.Exported, funcDef.Name, funcDef.ExternSymbol, parameters, funcDef.Signature.ReturnType);
|
||||
break;
|
||||
}
|
||||
case StructSyntax structDef:
|
||||
{
|
||||
var fields = structDef.Fields
|
||||
.Select(x => new ModuleStructField(x.Name, x.Type, x.Value.HasValue))
|
||||
.ToList();
|
||||
|
||||
var functions = structDef.Functions
|
||||
.Select(x =>
|
||||
{
|
||||
var parameters = x.Signature.Parameters
|
||||
.Select(y => new ModuleFunctionParameter(y.Name, y.Type))
|
||||
.ToList();
|
||||
|
||||
return new ModuleStructFunction(x.Name, x.Hook, parameters, x.Signature.ReturnType);
|
||||
})
|
||||
.ToList();
|
||||
|
||||
module.RegisterStruct(structDef.Exported, structDef.Name, fields, functions);
|
||||
break;
|
||||
}
|
||||
case StructTemplateSyntax structDef:
|
||||
{
|
||||
module.RegisterStructTemplate(structDef);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(definition));
|
||||
}
|
||||
}
|
||||
module.Register(definition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user