示例#1
0
        public override void OnReferenceExpression(ReferenceExpression node)
        {
            IEntity entity = NameResolutionService.Resolve(node.Name);

            //search for the left side of a key in a hash literal expression
            if (node.ParentNode is ExpressionPair &&
                ((ExpressionPair)node.ParentNode).First == node &&
                node.ParentNode.ParentNode is HashLiteralExpression)
            {
                ExpressionPair          parent  = (ExpressionPair)node.ParentNode;
                StringLiteralExpression literal = CodeBuilder.CreateStringLiteral(node.Name);
                parent.First = literal;
                parent.Replace(node, literal);
                return;
            }
            base.OnReferenceExpression(node);
        }
示例#2
0
        public override void OnReferenceExpression(ReferenceExpression node)
        {
            IEntity entity = NameResolutionService.Resolve(node.Name);

            if (entity != null)
            {
                base.OnReferenceExpression(node);
                return;
            }
            if (node.Name.StartsWith("@"))
            {
                ReplaceWithComponentReference(node, node.Name);
                return;
            }
            else if (node.ParentNode is ExpressionPair)
            {
                ExpressionPair          pair    = (ExpressionPair)node.ParentNode;
                StringLiteralExpression literal = CodeBuilder.CreateStringLiteral(node.Name);
                pair.Replace(node, literal);
                return;
            }
            else if (
                //search for the left side of a key in a hash literal expression
                node.ParentNode is ExpressionPair &&
                ((ExpressionPair)node.ParentNode).First == node &&
                node.ParentNode.ParentNode is HashLiteralExpression)
            {
                ExpressionPair          parent  = (ExpressionPair)node.ParentNode;
                StringLiteralExpression literal = CodeBuilder.CreateStringLiteral(node.Name);
                parent.First = literal;
                parent.Replace(node, literal);
                return;
            }

            base.OnReferenceExpression(node);
        }