Example #1
0
        override public object Clone()
        {
            UnpackStatement clone = (UnpackStatement)FormatterServices.GetUninitializedObject(typeof(UnpackStatement));

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }

            if (null != _modifier)
            {
                clone._modifier = _modifier.Clone() as StatementModifier;
                clone._modifier.InitializeParent(clone);
            }
            if (null != _declarations)
            {
                clone._declarations = _declarations.Clone() as DeclarationCollection;
                clone._declarations.InitializeParent(clone);
            }
            if (null != _expression)
            {
                clone._expression = _expression.Clone() as Expression;
                clone._expression.InitializeParent(clone);
            }
            return(clone);
        }
Example #2
0
 public UnpackStatement CreateUnpackStatement(DeclarationCollection declarations, Expression expression)
 {
     UnpackStatement unpack = new UnpackStatement(expression.LexicalInfo);
     unpack.Declarations.AddRange(declarations);
     unpack.Expression = expression;
     return unpack;
 }
Example #3
0
        public override void OnUnpackStatement(UnpackStatement node)
        {
            Visit(node.Expression);

            node.Expression = GetCorrectIterator(node.Expression);

            IType defaultDeclarationType = GetEnumeratorItemType(GetExpressionType(node.Expression));
            foreach (Declaration d in node.Declarations)
            {
                bool declareNewVariable = d.Type != null;

                GetDeclarationType(defaultDeclarationType, d);
                if (declareNewVariable)
                {
                    AssertUniqueLocal(d);
                }
                else
                {
                    IEntity entity = TryToResolveName(d.Name);
                    if (null != entity)
                    {
                        Bind(d, entity);
                        AssertLValue(d, entity);
                        continue;
                    }
                }
                DeclareLocal(d, false);
            }
        }
Example #4
0
	protected UnpackStatement  unpack() //throws RecognitionException, TokenStreamException
{
		UnpackStatement s;
		
		IToken  t = null;
		
			Declaration d = null;
			s = new UnpackStatement();
			Expression e = null;
		
		
		try {      // for error handling
			d=declaration();
			match(COMMA);
			if (0==inputState.guessing)
			{
				s.Declarations.Add(d);
			}
			{
				switch ( LA(1) )
				{
				case ID:
				{
					declaration_list(s.Declarations);
					break;
				}
				case ASSIGN:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			t = LT(1);
			match(ASSIGN);
			e=array_or_expression();
			if (0==inputState.guessing)
			{
				
						s.Expression = e;
						s.LexicalInfo = ToLexicalInfo(t);
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "unpack");
				recover(ex,tokenSet_90_);
			}
			else
			{
				throw ex;
			}
		}
		return s;
	}
Example #5
0
 public override void OnUnpackStatement(UnpackStatement node)
 {
     NotImplemented("Unpacking");
 }
		public override void OnUnpackStatement(UnpackStatement node)
		{
			ArrayLiteralExpression ale = node.Expression as ArrayLiteralExpression;
			for (int i = 0; i < node.Declarations.Count; i++) {
				Declaration decl = node.Declarations[i];
				if (acceptImplicit && ale != null && ale.Items.Count > i) {
					DeclarationFound(decl.Name, decl.Type, ale.Items[i], decl.LexicalInfo);
				} else if (decl.Type != null) {
					DeclarationFound(decl.Name, decl.Type, null, decl.LexicalInfo);
				}
			}
		}
 public override void LeaveUnpackStatement(UnpackStatement node)
 {
     LeaveStatement(node);
 }
Example #8
0
		override public object Clone()
		{
		
			UnpackStatement clone = new UnpackStatement();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			if (null != _modifier)
			{
				clone._modifier = _modifier.Clone() as StatementModifier;
				clone._modifier.InitializeParent(clone);
			}
			if (null != _declarations)
			{
				clone._declarations = _declarations.Clone() as DeclarationCollection;
				clone._declarations.InitializeParent(clone);
			}
			if (null != _expression)
			{
				clone._expression = _expression.Clone() as Expression;
				clone._expression.InitializeParent(clone);
			}
			return clone;


		}
		override public void LeaveUnpackStatement(UnpackStatement node)
		{
			Block body = new Block(node.LexicalInfo);
			UnpackExpression(body, node.Expression, node.Declarations);
			ReplaceCurrentNode(body);
		}
Example #10
0
 public override void OnUnpackStatement(UnpackStatement us)
 {
     WriteIndented();
     for (int i=0; i<us.Declarations.Count; ++i)
     {
         if (i > 0)
         {
             Write(", ");
         }
         Visit(us.Declarations[i]);
     }
     WriteOperator(" = ");
     Visit(us.Expression);
     Visit(us.Modifier);
     WriteLine();
 }