Skip to content

Commit

Permalink
ReturnType implemented on each subclass
Browse files Browse the repository at this point in the history
  • Loading branch information
TyOverby committed May 10, 2017
1 parent 229e33e commit a54e0ce
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ internal abstract class SynthesizedEntryPointSymbol : MethodSymbol
internal const string FactoryName = "<Factory>";

private readonly NamedTypeSymbol _containingType;
private TypeSymbol _returnType;

internal static SynthesizedEntryPointSymbol Create(SynthesizedInteractiveInitializerMethod initializerMethod, DiagnosticBag diagnostics)
{
Expand Down Expand Up @@ -56,12 +55,11 @@ internal static SynthesizedEntryPointSymbol Create(SynthesizedInteractiveInitial
}
}

private SynthesizedEntryPointSymbol(NamedTypeSymbol containingType, TypeSymbol returnType = null)
private SynthesizedEntryPointSymbol(NamedTypeSymbol containingType)
{
Debug.Assert((object)containingType != null);

_containingType = containingType;
_returnType = returnType;
}

internal override bool GenerateDebugInfo
Expand Down Expand Up @@ -129,11 +127,6 @@ internal override RefKind RefKind
get { return RefKind.None; }
}

public override TypeSymbol ReturnType
{
get { return _returnType; }
}

public override ImmutableArray<CustomModifier> ReturnTypeCustomModifiers
{
get { return ImmutableArray<CustomModifier>.Empty; }
Expand Down Expand Up @@ -161,7 +154,7 @@ public override int Arity

public override bool ReturnsVoid
{
get { return _returnType.SpecialType == SpecialType.System_Void; }
get { return ReturnType.SpecialType == SpecialType.System_Void; }
}

public override MethodKind MethodKind
Expand Down Expand Up @@ -371,8 +364,6 @@ internal AsyncForwardEntryPoint(CSharpCompilation compilation, DiagnosticBag dia

var success = binder.GetAwaitableExpressionInfo(userMainInvocation, out _, out _, out _, out _getAwaiterGetResultCall, _userMainReturnTypeSyntax, diagnosticBag);

_returnType = _getAwaiterGetResultCall.Type;

Debug.Assert(
ReturnType.SpecialType == SpecialType.System_Void ||
ReturnType.SpecialType == SpecialType.System_Int32);
Expand All @@ -382,6 +373,8 @@ internal AsyncForwardEntryPoint(CSharpCompilation compilation, DiagnosticBag dia

public override ImmutableArray<ParameterSymbol> Parameters => _parameters;

public override TypeSymbol ReturnType => _getAwaiterGetResultCall.Type;

internal override BoundBlock CreateBody()
{
var syntax = _userMainReturnTypeSyntax;
Expand Down Expand Up @@ -430,21 +423,25 @@ private sealed class ScriptEntryPoint : SynthesizedEntryPointSymbol
{
private readonly MethodSymbol _getAwaiterMethod;
private readonly MethodSymbol _getResultMethod;
private readonly TypeSymbol _returnType;

internal ScriptEntryPoint(NamedTypeSymbol containingType, TypeSymbol returnType, MethodSymbol getAwaiterMethod, MethodSymbol getResultMethod) :
base(containingType, returnType)
base(containingType)
{
Debug.Assert(containingType.IsScriptClass);
Debug.Assert(returnType.SpecialType == SpecialType.System_Void);

_getAwaiterMethod = getAwaiterMethod;
_getResultMethod = getResultMethod;
_returnType = returnType;
}

public override string Name => MainName;

public override ImmutableArray<ParameterSymbol> Parameters => ImmutableArray<ParameterSymbol>.Empty;

public override TypeSymbol ReturnType => _returnType;

// private static void <Main>()
// {
// var script = new Script();
Expand Down Expand Up @@ -514,13 +511,15 @@ internal override BoundBlock CreateBody()
private sealed class SubmissionEntryPoint : SynthesizedEntryPointSymbol
{
private readonly ImmutableArray<ParameterSymbol> _parameters;
private readonly TypeSymbol _returnType;

internal SubmissionEntryPoint(NamedTypeSymbol containingType, TypeSymbol returnType, TypeSymbol submissionArrayType) :
base(containingType, returnType)
base(containingType)
{
Debug.Assert(containingType.IsSubmissionClass);
Debug.Assert(returnType.SpecialType != SpecialType.System_Void);
_parameters = ImmutableArray.Create<ParameterSymbol>(SynthesizedParameterSymbol.Create(this, submissionArrayType, 0, RefKind.None, "submissionArray"));
_returnType = returnType;
}

public override string Name
Expand All @@ -533,6 +532,8 @@ public override ImmutableArray<ParameterSymbol> Parameters
get { return _parameters; }
}

public override TypeSymbol ReturnType => _returnType;

// private static T <Factory>(object[] submissionArray)
// {
// var submission = new Submission#N(submissionArray);
Expand Down

0 comments on commit a54e0ce

Please sign in to comment.