Пример #1
0
 public VariableFlags IdentifierName(
     INameExpression nameExpression,
     VariableFlags liveVariables)
 {
     SetLiveness(nameExpression.ReferencedSymbol, nameExpression.VariableIsLiveAfter, liveVariables);
     return(liveVariables.Set(nameExpression.ReferencedSymbol, true));
 }
        public VariableFlags IdentifierName(
            INameExpression nameExpression,
            VariableFlags possiblyMoved)
        {
            var symbol = nameExpression.ReferencedSymbol;

            if (possiblyMoved[symbol] == true)
            {
                diagnostics.Add(SemanticError.UseOfPossiblyMovedValue(file, nameExpression.Span));
            }

            var valueSemantics = nameExpression.Semantics;

            // TODO this isn't correct, but for now fields don't have proper move, borrow handling
            //?? nameExpression.Type.Assigned().OldValueSemantics;
            switch (valueSemantics)
            {
            case ExpressionSemantics.Move:
            case ExpressionSemantics.Acquire:
                return(possiblyMoved.Set(symbol, true));

            case ExpressionSemantics.Copy:
            case ExpressionSemantics.Borrow:
            case ExpressionSemantics.Share:
            case ExpressionSemantics.Void:
            case ExpressionSemantics.Never:
            case ExpressionSemantics.CreateReference:
                // If it were move or copy, that would have been set to the ExpressionSemantics
                // Not moving value
                return(possiblyMoved);

            default:
                throw ExhaustiveMatch.Failed(valueSemantics);
            }
        }
Пример #3
0
 public ForCatchExpression(INameExpression index, IRightExpression begin, IRightExpression end, IExpression entry)
 {
     _index = index;
     _begin = begin;
     _end   = end;
     _step  = new NumberExpression(1);
     _entry = new FuncExpression(new[] { _index.Name }, entry);
 }
Пример #4
0
 public ForExpression(INameExpression index, IRightExpression begin, IRightExpression end, IRightExpression step, IExpression entry)
 {
     _index = index;
     _begin = begin;
     _end   = end;
     _step  = step;
     _entry = entry;
 }
 public VariableFlags Assignment(
     IAssignmentExpression assignmentExpression,
     VariableFlags definitelyAssigned)
 {
     return(assignmentExpression.LeftOperand switch
     {
         INameExpression identifier =>
         definitelyAssigned.Set(identifier.ReferencedSymbol, true),
         IFieldAccessExpression _ => definitelyAssigned,
         _ => throw new NotImplementedException("Complex assignments not yet implemented")
     });
Пример #6
0
 public ForEachCatchExpression(INameExpression index, IRightExpression list, IExpression entry)
 {
     _index = index;
     _list  = list;
     _entry = new FuncExpression(new[] { _index.Name }, entry);
 }
Пример #7
0
 public ForEachExpression(INameExpression index, IRightExpression list, IExpression entry)
 {
     _index = index;
     _list  = list;
     _entry = entry;
 }
Пример #8
0
 public virtual void ExitINameExpression(INameExpression iNameExpression)
 {
 }
Пример #9
0
 public virtual void EnterINameExpression(INameExpression iNameExpression)
 {
 }
Пример #10
0
 public PropertyExpression(IRightExpression target, INameExpression property)
 {
     _target   = target;
     _property = property;
 }
 public VariableFlags IdentifierName(
     INameExpression nameExpression,
     VariableFlags definitelyUnassigned)
 {
     return(definitelyUnassigned);
 }