Skip to content

Commit

Permalink
we have passed EmitterTests.Enum2 again
Browse files Browse the repository at this point in the history
  • Loading branch information
HAZAMA committed Jul 11, 2018
1 parent 6564319 commit 4bd421c
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 216 deletions.
13 changes: 8 additions & 5 deletions Expresso/Analysis/TypeChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ public AstType VisitAssignment(AssignmentExpression assignment)
TemporaryTypes.Clear();
assignment.AcceptWalker(inference_runner);

if(assignment.Left is SequenceExpression || assignment.Right is SequenceExpression){
if((assignment.Left is SequenceExpression sequence1 && sequence1.Items.Count > 1 || assignment.Right is SequenceExpression sequence2 && sequence2.Items.Count > 1)
&& assignment.Operator != OperatorType.Assign){
throw new ParserException(
"Augmented assignments can't have multiple items on each side.",
"ES2101",
Expand Down Expand Up @@ -1120,11 +1121,11 @@ public AstType VisitUnaryExpression(UnaryExpression unaryExpr)

public AstType VisitSelfReferenceExpression(SelfReferenceExpression selfRef)
{
// selfRef.SelfIdentifier is always type-aware at this point because MemberReference infers its target's type
/*if(selfRef.SelfIdentifier.Type is PlaceholderType){
// We need to infer this here because self can appear by itself
if(selfRef.SelfIdentifier.Type is PlaceholderType){
inference_runner.VisitSelfReferenceExpression(selfRef);
BindTypeName(selfRef.SelfIdentifier.Type.IdentifierNode);
}*/
}

var type_table = symbols.GetTypeTable(selfRef.SelfIdentifier.Type.Name);
var next_sibling = selfRef.NextSibling;
Expand Down Expand Up @@ -1680,7 +1681,9 @@ public AstType VisitTuplePattern(TuplePattern tuplePattern)
from p in tuplePattern.Patterns
select p.AcceptWalker(this).Clone();
// TODO: consider the case that the tuple contains an IgnoringRestPattern
return AstType.MakeSimpleType("tuple", types, tuplePattern.StartLocation, tuplePattern.EndLocation);
var tuple_type = AstType.MakeSimpleType("tuple", types, tuplePattern.StartLocation, tuplePattern.EndLocation);
tuplePattern.ResolvedType = tuple_type;
return tuple_type;
}

public AstType VisitExpressionPattern(ExpressionPattern exprPattern)
Expand Down
4 changes: 2 additions & 2 deletions Expresso/Ast/GeneralScope/AliasDeclaration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Expresso.Ast
/// Represents an alias declaration.
/// An alias declaration, as the name implies, introduces a new name that corresponds to
/// an existing type, a module-level variable or a module itself.
/// "alias" PathExpression Identifier ';' ;
/// "alias" Identifier PathExpression ';' ;
/// </summary>
public class AliasDeclaration : AstNode
{
Expand Down Expand Up @@ -39,7 +39,7 @@ public Identifier AliasToken{
public AliasDeclaration(PathExpression path, string alias)
{
Path = path;
AliasToken = AstNode.MakeIdentifier(alias);
AliasToken = MakeIdentifier(alias);
}

#region implemented abstract members of AstNode
Expand Down
14 changes: 11 additions & 3 deletions Expresso/Ast/Patterns/TuplePattern.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.PatternMatching;

namespace Expresso.Ast
Expand All @@ -18,6 +16,16 @@ public class TuplePattern : PatternConstruct
/// </summary>
public AstNodeCollection<PatternConstruct> Patterns => GetChildrenByRole(Roles.Pattern);

/// <summary>
/// Represents the resolved type as <see cref="SimpleType"/>.
/// Will be resolved in <see cref="Analysis.TypeChecker"/>
/// </summary>
/// <value>The type of the resolved.</value>
public SimpleType ResolvedType{
get => GetChildByRole(Roles.GenericType);
set => SetChildByRole(Roles.GenericType, value);
}

public TuplePattern(IEnumerable<PatternConstruct> patterns)
: base(patterns.First().StartLocation, patterns.Last().EndLocation)
{
Expand Down
43 changes: 34 additions & 9 deletions Expresso/CodeGen/CSharpEmitterContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,41 @@ public Type ContextClosureType{
}

/// <summary>
/// It will be set to a ParameterExpression that represents the temporary variable.
/// It will be set to a <see cref="LocalBuilder"/> that represents the temporary variable.
/// </summary>
public System.Linq.Expressions.ParameterExpression TemporaryVariable{
public LocalBuilder TemporaryVariable{
get; set;
}

/// <summary>
/// Current context <see cref="LocalBuilder"/>.
/// </summary>
/// <value>The current target variable.</value>
public LocalBuilder CurrentTargetVariable{
get; set;
}

/// <summary>
/// Current label that conditional or label jumps to.
/// </summary>
/// <value>The current else label.</value>
public Label CurrentOrTargetLabel{
get; set;
}

/// <summary>
/// Current label that conditional and label jumps to.
/// </summary>
/// <value>The current and target label.</value>
public Label CurrentAndTargetLabel{
get; set;
}

/// <summary>
/// Current jump label that the current match pattern clause should jump to after it is executed.
/// </summary>
/// <value>The current jump label.</value>
public Label CurrentJumpLabel{
get; set;
}

Expand Down Expand Up @@ -248,13 +280,6 @@ public int ParameterIndex{
public bool ExpectsReference{
get; set;
}

/// <summary>
/// Indicates whether to emit IL codes or not.
/// </summary>
public bool ShouldEmit{
get; set;
}
}
}

Loading

0 comments on commit 4bd421c

Please sign in to comment.