コード例 #1
0
        override public object Clone()
        {
            HashLiteralExpression clone = new HashLiteralExpression();

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }
            clone._expressionType = _expressionType;
            if (null != _items)
            {
                clone._items = _items.Clone() as ExpressionPairCollection;
                clone._items.InitializeParent(clone);
            }
            return(clone);
        }
コード例 #2
0
        override public object Clone()
        {
            HashLiteralExpression clone = (HashLiteralExpression)FormatterServices.GetUninitializedObject(typeof(HashLiteralExpression));

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

            clone._expressionType = _expressionType;
            if (null != _items)
            {
                clone._items = _items.Clone() as ExpressionPairCollection;
                clone._items.InitializeParent(clone);
            }
            return(clone);
        }
コード例 #3
0
ファイル: EmitAssembly.cs プロジェクト: Bombadil77/boo
        public override void OnHashLiteralExpression(HashLiteralExpression node)
        {
            _il.Emit(OpCodes.Newobj, Hash_Constructor);

            IType objType = TypeSystemServices.ObjectType;
            foreach (ExpressionPair pair in node.Items)
            {
                _il.Emit(OpCodes.Dup);

                Visit(pair.First);
                EmitCastIfNeeded(objType, PopType());

                Visit(pair.Second);
                EmitCastIfNeeded(objType, PopType());
                _il.EmitCall(OpCodes.Callvirt, Hash_Add, null);
            }

            PushType(TypeSystemServices.HashType);
        }
コード例 #4
0
ファイル: EmitAssembly.cs プロジェクト: hlizard/boo
		override public void OnHashLiteralExpression(HashLiteralExpression node)
		{
			_il.Emit(OpCodes.Newobj, Hash_Constructor);

			var objType = TypeSystemServices.ObjectType;
			foreach (ExpressionPair pair in node.Items)
			{
				Dup();

				LoadExpressionWithType(objType, pair.First);
				LoadExpressionWithType(objType, pair.Second);
				_il.EmitCall(OpCodes.Callvirt, Hash_Add, null);
			}

			PushType(TypeSystemServices.HashType);
		}
コード例 #5
0
        private bool BuildConfigurationNode(BinaryExpression node, bool asAttribute,
		                                    HashLiteralExpression configuration)
        {
            var nodeVisitor = new ConfigurationNodeVisitor();
            if (!nodeVisitor.GetNode(node.Left, asAttribute, _compileErrors)) return false;

            if (nodeVisitor.IsAttribute || asAttribute)
            {
                return BuildConfigurationAttribute(nodeVisitor.Node, node.Right, configuration);
            }

            if ((_skip =_attributesOnly) == false)
            {
                return BuildConfigurationChild(nodeVisitor.Node, node.Right);
            }

            return true;
        }
コード例 #6
0
        private bool BuildConfigurationChild(Expression child, Expression value, ICollection<Expression> attributes)
        {
            child = EnsureUniqueChild(child);

            if (attributes != null && attributes.Count > 0)
            {
                var childAttributes = new HashLiteralExpression();
                if (value != null)
                {
                    childAttributes.Items.Add(new ExpressionPair(new StringLiteralExpression("value"), value));
                }

                // child=value, attrib2=value2: Child with attributes
                foreach(var attribute in attributes)
                {
                    if (BuildAttribute(attribute, childAttributes) == false)
                    {
                        return false;
                    }
                }

                _configuration.Items.Add(new ExpressionPair(child, childAttributes));
            }
            else
            {
                // child=value: Child without attributes
                _configuration.Items.Add(new ExpressionPair(child, value ?? new StringLiteralExpression("")));
            }

            return true;
        }
コード例 #7
0
        private bool BuildConfigurationAttribute(Expression node, Expression value,
		                                         HashLiteralExpression configuration)
        {
            ArrayLiteralExpression attributes;
            if (MacroHelper.IsCompoundAssignment(value, out attributes))
            {
                // @attrib1=value1, attrib2=value2: Multiple attributes

                foreach(var attribute in attributes.Items)
                {
                    if (attribute == attributes.Items[0])
                    {
                        configuration.Items.Add(new ExpressionPair(node, attribute));
                    }
                    else if (BuildAttribute(attribute, configuration) == false)
                    {
                        return false;
                    }
                }
            }
            else
            {
                // @attrib=value: Single attribute
                configuration.Items.Add(new ExpressionPair(node, value));
            }

            return true;
        }
コード例 #8
0
        private bool BuildAttribute(Expression expression, HashLiteralExpression configuration)
        {
            BinaryExpression attribute;
            if (MacroHelper.IsAssignment(expression, out attribute))
            {
                BuildConfigurationNode(attribute, true, configuration);
            }
            else
            {
                _compileErrors.Add(CompilerErrorFactory.CustomError(expression.LexicalInfo,
                    "Attributes must be in the format @attrib1=value1, attrib2=value2,..."));
                return false;
            }

            return true;
        }
コード例 #9
0
        public HashLiteralExpression hash_literal()
        {
            HashLiteralExpression expression = null;
            IToken token = null;
            ExpressionPair pair = null;
            try
            {
                token = this.LT(1);
                this.match(0x3d);
                if (base.inputState.guessing == 0)
                {
                    expression = new HashLiteralExpression(ToLexicalInfo(token));
                }
                switch (this.LA(1))
                {
                    case 12:
                    case 15:
                    case 0x13:
                    case 0x1b:
                    case 0x1d:
                    case 0x27:
                    case 40:
                    case 0x2a:
                    case 0x2c:
                    case 0x3b:
                    case 60:
                    case 0x3d:
                    case 0x3f:
                    case 0x44:
                    case 0x4f:
                    case 80:
                    case 0x52:
                    case 0x58:
                    case 0x67:
                    case 0x69:
                    case 0x6a:
                    case 0x6b:
                    case 0x6c:
                    case 0x6d:
                        pair = this.expression_pair();
                        if (base.inputState.guessing == 0)
                        {
                            expression.get_Items().Add(pair);
                        }
                        while (this.LA(1) == 0x43)
                        {
                            this.match(0x43);
                            pair = this.expression_pair();
                            if (base.inputState.guessing == 0)
                            {
                                expression.get_Items().Add(pair);
                            }
                        }
                        break;

                    case 0x3e:
                        break;

                    default:
                        throw new NoViableAltException(this.LT(1), this.getFilename());
                }
                this.match(0x3e);
            }
            catch (RecognitionException exception)
            {
                if (base.inputState.guessing != 0)
                {
                    throw;
                }
                this.reportError(exception);
                this.recover(exception, tokenSet_20_);
                return expression;
            }
            return expression;
        }
コード例 #10
0
		public override void OnHashLiteralExpression(HashLiteralExpression node)
		{
			MakeLiteralResult("Boo.Lang.Hash");
		}
コード例 #11
0
 public override void LeaveHashLiteralExpression(HashLiteralExpression node)
 {
     foreach (ExpressionPair pair in node.Items)
     {
         CheckExpressionType(pair.First);
         CheckExpressionType(pair.Second);
     }
 }
コード例 #12
0
		override public object Clone()
		{
		
			HashLiteralExpression clone = new HashLiteralExpression();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._expressionType = _expressionType;
			if (null != _items)
			{
				clone._items = _items.Clone() as ExpressionPairCollection;
				clone._items.InitializeParent(clone);
			}
			return clone;


		}
コード例 #13
0
 private bool checkAll(ReferenceExpression node){
     if(node.ToCodeString()=="@__"){
         var list = new HashLiteralExpression();
         foreach (var namedarg in namedargs){
             list.Items.Add(
                 new ExpressionPair(
                     namedarg.Key.toLiteral(),
                     namedarg.Value.CloneNode()
                     ));
                 
         }
         node.ParentNode.Replace(node, list);
         return true;
     }
     return false;
 }
コード例 #14
0
 public override void OnHashLiteralExpression(HashLiteralExpression node)
 {
     Write("{");
     if (node.Items.Count > 0)
     {
         Write(" ");
         WriteCommaSeparatedList(node.Items);
         Write(" ");
     }
     Write("}");
 }
コード例 #15
0
ファイル: BooParserBase.cs プロジェクト: hlizard/boo
	protected HashLiteralExpression  hash_literal() //throws RecognitionException, TokenStreamException
{
		HashLiteralExpression dle;
		
		IToken  lbrace = null;
		
				dle = null;
				ExpressionPair pair = null;
			
		
		try {      // for error handling
			lbrace = LT(1);
			match(LBRACE);
			if (0==inputState.guessing)
			{
				dle = new HashLiteralExpression(ToLexicalInfo(lbrace));
			}
			{
				switch ( LA(1) )
				{
				case ESEPARATOR:
				case CAST:
				case CHAR:
				case FALSE:
				case NOT:
				case NULL:
				case SELF:
				case SUPER:
				case THEN:
				case TRUE:
				case TYPEOF:
				case TRIPLE_QUOTED_STRING:
				case LPAREN:
				case DOUBLE_QUOTED_STRING:
				case SINGLE_QUOTED_STRING:
				case ID:
				case MULTIPLY:
				case LBRACK:
				case SPLICE_BEGIN:
				case DOT:
				case LBRACE:
				case QQ_BEGIN:
				case SUBTRACT:
				case LONG:
				case INCREMENT:
				case DECREMENT:
				case ONES_COMPLEMENT:
				case INT:
				case BACKTICK_QUOTED_STRING:
				case RE_LITERAL:
				case DOUBLE:
				case FLOAT:
				case TIMESPAN:
				{
					pair=expression_pair();
					if (0==inputState.guessing)
					{
						dle.Items.Add(pair);
					}
					{    // ( ... )*
						for (;;)
						{
							if ((LA(1)==COMMA) && (tokenSet_5_.member(LA(2))))
							{
								match(COMMA);
								pair=expression_pair();
								if (0==inputState.guessing)
								{
									dle.Items.Add(pair);
								}
							}
							else
							{
								goto _loop642_breakloop;
							}
							
						}
_loop642_breakloop:						;
					}    // ( ... )*
					{
						switch ( LA(1) )
						{
						case COMMA:
						{
							match(COMMA);
							break;
						}
						case RBRACE:
						{
							break;
						}
						default:
						{
							throw new NoViableAltException(LT(1), getFilename());
						}
						 }
					}
					break;
				}
				case RBRACE:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			match(RBRACE);
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "hash_literal");
				recover(ex,tokenSet_44_);
			}
			else
			{
				throw ex;
			}
		}
		return dle;
	}
コード例 #16
0
ファイル: ProcessMethodBodies.cs プロジェクト: stuman08/boo
 public override void LeaveHashLiteralExpression(HashLiteralExpression node)
 {
     BindExpressionType(node, TypeSystemServices.HashType);
     foreach (ExpressionPair pair in node.Items)
     {
         GetConcreteExpressionType(pair.First);
         GetConcreteExpressionType(pair.Second);
     }
 }
コード例 #17
0
 private bool Build(Block block, bool attributesOnly, CompilerErrorCollection compileErrors)
 {
     _attributesOnly = attributesOnly;
     _compileErrors = compileErrors;
     _configuration = new HashLiteralExpression();
     _childContext = new Dictionary<string, object>();
     return BuildHashConfiguration(block);
 }