Remove implicit this for now
This commit is contained in:
@@ -1,16 +1,6 @@
|
||||
extern func puts(fmt: cstring)
|
||||
|
||||
interface Printable
|
||||
{
|
||||
func print()
|
||||
}
|
||||
|
||||
interface Stringable
|
||||
{
|
||||
func str(): cstring
|
||||
}
|
||||
|
||||
struct Human : Printable, Stringable
|
||||
struct Human
|
||||
{
|
||||
name: cstring
|
||||
|
||||
@@ -18,11 +8,6 @@ struct Human : Printable, Stringable
|
||||
{
|
||||
return this.name
|
||||
}
|
||||
|
||||
func print()
|
||||
{
|
||||
puts(this.str())
|
||||
}
|
||||
}
|
||||
|
||||
func main(args: []cstring): i64
|
||||
@@ -32,7 +17,6 @@ func main(args: []cstring): i64
|
||||
}
|
||||
|
||||
puts(human.str())
|
||||
// human.print()
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -413,12 +413,10 @@ public partial class QBEGenerator
|
||||
|
||||
private Val EmitStructFuncAccess(StructFuncAccessNode structFuncAccess)
|
||||
{
|
||||
var target = EmitUnwrap(EmitExpression(structFuncAccess.Target));
|
||||
|
||||
var structDef = _definitionTable.LookupStruct(structFuncAccess.StructType.Name);
|
||||
var func = StructFuncName(structDef.Name, structFuncAccess.Func);
|
||||
|
||||
return new Val(func, structFuncAccess.Type, ValKind.Direct, target);
|
||||
return new Val(func, structFuncAccess.Type, ValKind.Direct);
|
||||
}
|
||||
|
||||
private Val EmitInterfaceFuncAccess(InterfaceFuncAccessNode interfaceFuncAccess)
|
||||
@@ -438,13 +436,7 @@ public partial class QBEGenerator
|
||||
var func = TmpName();
|
||||
_writer.Indented($"{func} =l loadl {funcOffset}");
|
||||
|
||||
var dataPointer = TmpName();
|
||||
_writer.Indented($"{dataPointer} =l add {target}, 8");
|
||||
|
||||
var data = TmpName();
|
||||
_writer.Indented($"{data} =l loadl {dataPointer}");
|
||||
|
||||
return new Val(func, interfaceFuncAccess.Type, ValKind.Direct, data);
|
||||
return new Val(func, interfaceFuncAccess.Type, ValKind.Direct);
|
||||
}
|
||||
|
||||
private Val EmitInterfaceInitializer(InterfaceInitializerNode interfaceInitializer, string? destination = null)
|
||||
@@ -484,10 +476,6 @@ public partial class QBEGenerator
|
||||
var expression = EmitExpression(funcCall.Expression);
|
||||
|
||||
var parameterStrings = new List<string>();
|
||||
if (expression.ThisArg != null)
|
||||
{
|
||||
parameterStrings.Add($"l {expression.ThisArg}");
|
||||
}
|
||||
|
||||
foreach (var parameter in funcCall.Parameters)
|
||||
{
|
||||
|
||||
@@ -623,7 +623,7 @@ public class CStringLiteral(string value, string name)
|
||||
public string Name { get; } = name;
|
||||
}
|
||||
|
||||
public record Val(string Name, TypeNode Type, ValKind Kind, string? ThisArg = null);
|
||||
public record Val(string Name, TypeNode Type, ValKind Kind);
|
||||
|
||||
public class Scope(Scope? parent = null)
|
||||
{
|
||||
|
||||
@@ -66,16 +66,11 @@ public sealed class Parser
|
||||
return new SyntaxTree(GetTokens(_tokenIndex), definitions);
|
||||
}
|
||||
|
||||
private FuncSignatureSyntax ParseFuncSignature(TypeSyntax? thisArg = null)
|
||||
private FuncSignatureSyntax ParseFuncSignature()
|
||||
{
|
||||
var startIndex = _tokenIndex;
|
||||
List<FuncParameterSyntax> parameters = [];
|
||||
|
||||
if (thisArg != null)
|
||||
{
|
||||
parameters.Add(new FuncParameterSyntax([], "this", thisArg));
|
||||
}
|
||||
|
||||
ExpectSymbol(Symbol.OpenParen);
|
||||
|
||||
while (!TryExpectSymbol(Symbol.CloseParen))
|
||||
@@ -175,7 +170,7 @@ public sealed class Parser
|
||||
if (TryExpectSymbol(Symbol.Func))
|
||||
{
|
||||
var funcName = ExpectIdentifier().Value;
|
||||
var funcSignature = ParseFuncSignature(new CustomTypeSyntax([], name.Value));
|
||||
var funcSignature = ParseFuncSignature();
|
||||
var funcBody = ParseBlock();
|
||||
|
||||
funcs.Add(new StructFuncSyntax(GetTokens(memberStartIndex), funcName, funcSignature, funcBody));
|
||||
|
||||
Reference in New Issue
Block a user