...
This commit is contained in:
@@ -12,25 +12,25 @@ public sealed class BoundDefinitionTable
|
||||
_definitions = syntaxTrees.SelectMany(x => x.Definitions).ToList();
|
||||
}
|
||||
|
||||
public BoundLocalFunc LookupLocalFunc(string @namespace, string name)
|
||||
public BoundLocalFunc LookupLocalFunc(string name)
|
||||
{
|
||||
return _definitions
|
||||
.OfType<BoundLocalFunc>()
|
||||
.First(x => x.Namespace == @namespace && x.Name == name);
|
||||
.First(x => x.Name == name);
|
||||
}
|
||||
|
||||
public BoundExternFunc LookupExternFunc(string @namespace, string name)
|
||||
public BoundExternFunc LookupExternFunc(string name)
|
||||
{
|
||||
return _definitions
|
||||
.OfType<BoundExternFunc>()
|
||||
.First(x => x.Namespace == @namespace && x.Name == name);
|
||||
.First(x => x.Name == name);
|
||||
}
|
||||
|
||||
public BoundStruct LookupStruct(string @namespace, string name)
|
||||
public BoundStruct LookupStruct(string name)
|
||||
{
|
||||
return _definitions
|
||||
.OfType<BoundStruct>()
|
||||
.First(x => x.Namespace == @namespace && x.Name == name);
|
||||
.First(x => x.Name == name);
|
||||
}
|
||||
|
||||
public BoundStructField LookupStructField(BoundStruct @struct, string field)
|
||||
@@ -54,11 +54,11 @@ public sealed class BoundDefinitionTable
|
||||
.First(x => x.Name == name);
|
||||
}
|
||||
|
||||
public BoundTrait LookupTrait(string @namespace, string name)
|
||||
public BoundTrait LookupTrait(string name)
|
||||
{
|
||||
return _definitions
|
||||
.OfType<BoundTrait>()
|
||||
.First(x => x.Namespace == @namespace && x.Name == name);
|
||||
.First(x => x.Name == name);
|
||||
}
|
||||
|
||||
public BoundTraitFunc LookupTraitFunc(BoundTrait trait, string name)
|
||||
|
||||
@@ -224,13 +224,13 @@ public partial class QBEGenerator
|
||||
|
||||
private Val EmitExternFuncIdent(BoundExternFuncIdent externFuncIdent)
|
||||
{
|
||||
var func = _definitionTable.LookupExternFunc(externFuncIdent.Namespace, externFuncIdent.Name);
|
||||
var func = _definitionTable.LookupExternFunc(externFuncIdent.Name);
|
||||
return new Val(ExternFuncName(func), externFuncIdent.Type, ValKind.Direct);
|
||||
}
|
||||
|
||||
private Val EmitLocalFuncIdent(BoundLocalFuncIdent localFuncIdent)
|
||||
{
|
||||
var func = _definitionTable.LookupLocalFunc(localFuncIdent.Namespace, localFuncIdent.Name);
|
||||
var func = _definitionTable.LookupLocalFunc(localFuncIdent.Name);
|
||||
return new Val(LocalFuncName(func), localFuncIdent.Type, ValKind.Direct);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ public partial class QBEGenerator
|
||||
|
||||
private Val EmitStructInitializer(BoundStructInitializer structInitializer, string? destination = null)
|
||||
{
|
||||
var @struct = _definitionTable.LookupStruct(structInitializer.StructType.Namespace, structInitializer.StructType.Name);
|
||||
var @struct = _definitionTable.LookupStruct(structInitializer.StructType.Name);
|
||||
|
||||
if (destination == null)
|
||||
{
|
||||
@@ -400,7 +400,7 @@ public partial class QBEGenerator
|
||||
{
|
||||
var target = EmitUnwrap(EmitExpression(structFieldAccess.Target));
|
||||
|
||||
var structDef = _definitionTable.LookupStruct(structFieldAccess.StructType.Namespace, structFieldAccess.StructType.Name);
|
||||
var structDef = _definitionTable.LookupStruct(structFieldAccess.StructType.Name);
|
||||
var offset = OffsetOf(structDef, structFieldAccess.Field);
|
||||
|
||||
var output = TmpName();
|
||||
|
||||
@@ -373,7 +373,7 @@ public partial class QBEGenerator
|
||||
|
||||
private void EmitStructDefinition(BoundStruct structDef)
|
||||
{
|
||||
_writer.WriteLine($"type {CustomTypeName(structDef.Namespace, structDef.Name)} = {{ ");
|
||||
_writer.WriteLine($"type {CustomTypeName(structDef.Name)} = {{ ");
|
||||
|
||||
var types = new Dictionary<string, string>();
|
||||
|
||||
@@ -419,7 +419,7 @@ public partial class QBEGenerator
|
||||
|
||||
private void EmitTraitVTable(BoundTrait traitDef)
|
||||
{
|
||||
_writer.WriteLine($"type {CustomTypeName(traitDef.Namespace, traitDef.Name)} = {{");
|
||||
_writer.WriteLine($"type {CustomTypeName(traitDef.Name)} = {{");
|
||||
|
||||
foreach (var func in traitDef.Functions)
|
||||
{
|
||||
@@ -500,7 +500,7 @@ public partial class QBEGenerator
|
||||
|
||||
private string LocalFuncName(BoundLocalFunc funcDef)
|
||||
{
|
||||
return $"${funcDef.Namespace}_{funcDef.Name}";
|
||||
return $"${funcDef.Name}";
|
||||
}
|
||||
|
||||
private string ExternFuncName(BoundExternFunc funcDef)
|
||||
@@ -510,12 +510,12 @@ public partial class QBEGenerator
|
||||
|
||||
private string CustomTypeName(NubCustomType customType)
|
||||
{
|
||||
return CustomTypeName(customType.Namespace, customType.Name);
|
||||
return CustomTypeName(customType.Name);
|
||||
}
|
||||
|
||||
private string CustomTypeName(string @namespace, string name)
|
||||
private string CustomTypeName(string name)
|
||||
{
|
||||
return $":{@namespace}_{name}";
|
||||
return $":{name}";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user