示例#1
0
 override public void OnStatementModifier(StatementModifier sm)
 {
     Write(" ");
     WriteKeyword(sm.Type.ToString().ToLower());
     Write(" ");
     Visit(sm.Condition);
 }
示例#2
0
 public override void OnStatementModifier(StatementModifier sm)
 {
     Write(" ");
     Write(sm.Type.ToString().ToLower());
     Write(" ");
     Switch(sm.Condition);
 }
示例#3
0
 protected IteratorExpressionImpl(LexicalInfo lexicalInfo, Expression expression, Expression iterator, StatementModifier filter) : base(lexicalInfo)
 {
     _declarations = new DeclarationCollection(this);
     Expression    = expression;
     Iterator      = iterator;
     Filter        = filter;
 }
示例#4
0
        public static Statement MapStatementModifier(StatementModifier modifier, out Block block)
        {
            switch (modifier.Type)
            {
            case StatementModifierType.If:
            {
                IfStatement stmt = new IfStatement(modifier.LexicalInfo);
                stmt.Condition = modifier.Condition;
                stmt.TrueBlock = new Block();
                block          = stmt.TrueBlock;
                return(stmt);
            }

            case StatementModifierType.Unless:
            {
                UnlessStatement stmt = new UnlessStatement(modifier.LexicalInfo);
                stmt.Condition = modifier.Condition;
                block          = stmt.Block;
                return(stmt);
            }

            case StatementModifierType.While:
            {
                WhileStatement stmt = new WhileStatement(modifier.LexicalInfo);
                stmt.Condition = modifier.Condition;
                block          = stmt.Block;
                return(stmt);
            }
            }
            throw CompilerErrorFactory.NotImplemented(modifier, string.Format("modifier {0} supported", modifier.Type));
        }
示例#5
0
 protected IteratorExpressionImpl(Expression expression, Expression iterator, StatementModifier filter)
 {
     _declarations = new DeclarationCollection(this);
     Expression    = expression;
     Iterator      = iterator;
     Filter        = filter;
 }
示例#6
0
        public static Statement CreateModifiedStatement(StatementModifier modifier, Statement node)
        {
            Block     block;
            Statement stmt = MapStatementModifier(modifier, out block);

            block.Add(node);
            return(stmt);
        }
示例#7
0
        public override void Switch(IAstTransformer transformer, out Node resultingNode)
        {
            StatementModifier thisNode           = (StatementModifier)this;
            StatementModifier resultingTypedNode = thisNode;

            transformer.OnStatementModifier(thisNode, ref resultingTypedNode);
            resultingNode = resultingTypedNode;
        }
示例#8
0
        public void LeaveStatement(Statement node)
        {
            StatementModifier modifier = node.Modifier;

            if (null != modifier)
            {
                node.Modifier = null;
                ReplaceCurrentNode(CreateModifiedStatement(modifier, node));
            }
        }
示例#9
0
 public override void OnStatementModifier(StatementModifier node)
 {
     throw new NotImplementedException();
 }
示例#10
0
        override public void Apply(Boo.Lang.Compiler.Ast.Node node)
        {
            string name;
            Node   parent;
            string errorMessage = null;

            ParameterDeclaration pd = node as ParameterDeclaration;

            if (pd != null)
            {
                name   = pd.Name;
                parent = pd.ParentNode;
            }
            else
            {
                Property prop = node as Property;
                if (prop != null && prop.Setter != null)
                {
                    name   = "value";
                    parent = prop.Setter;
                }
                else
                {
                    InvalidNodeForAttribute("ParameterDeclaration or Property");
                    return;
                }
            }

            string            exceptionClass = null;
            StatementModifier modifier       = null;

            if (null == _condition)
            {
                exceptionClass = "ArgumentNullException";
                modifier       = new StatementModifier(
                    StatementModifierType.If,
                    new BinaryExpression(BinaryOperatorType.ReferenceEquality,
                                         new ReferenceExpression(name),
                                         new NullLiteralExpression()));
            }
            else
            {
                exceptionClass = "ArgumentException";
                modifier       = new StatementModifier(
                    StatementModifierType.Unless,
                    _condition);
                errorMessage = "Expected: " + _condition.ToString();
            }

            MethodInvocationExpression x = new MethodInvocationExpression();

            x.Target = new MemberReferenceExpression(
                new ReferenceExpression("System"),
                exceptionClass);
            if (null != errorMessage)
            {
                x.Arguments.Add(new StringLiteralExpression(errorMessage));
            }
            x.Arguments.Add(new StringLiteralExpression(name));

            RaiseStatement rs = new RaiseStatement(x, modifier);

            rs.LexicalInfo = LexicalInfo;

            Method method = parent as Method;

            if (null != method)
            {
                method.Body.Statements.Insert(0, rs);
            }
            else
            {
                Property property = (Property)parent;
                if (null != property.Getter)
                {
                    property.Getter.Body.Statements.Insert(0, rs);
                }
                if (null != property.Setter)
                {
                    property.Setter.Body.Statements.Insert(0, rs.CloneNode());
                }
            }
        }
 public override void OnStatementModifier(StatementModifier node)
 {
     base.OnStatementModifier(node);
     Check(node);
 }
示例#12
0
 protected StatementImpl(LexicalInfo lexicalInfo, StatementModifier modifier) : base(lexicalInfo)
 {
     Modifier = modifier;
 }
示例#13
0
 protected StatementImpl(StatementModifier modifier)
 {
     Modifier = modifier;
 }