Пример #1
0
        internal static void fall_true(EmitContext ec, AST ast, Label lbl)
        {
            Type type = ast.GetType();

            if (type == typeof(Expression))
            {
                Expression exp      = ast as Expression;
                AST        last_exp = (AST)exp.exprs [exp.exprs.Count - 1];
                if (exp.exprs.Count >= 2)
                {
                    exp.Emit(ec);
                }
                fall_true(ec, last_exp, lbl);
            }
            else if (type == typeof(Binary))
            {
                ft_binary_recursion(ec, ast, lbl);
            }
            else if (type == typeof(Equality) || type == typeof(StrictEquality))
            {
                ft_emit_equality(ec, ast, lbl);
            }
            else if (type == typeof(Relational))
            {
                ft_emit_relational(ec, (Relational)ast, lbl);
            }
            else
            {
                emit_default_case(ec, ast, OpCodes.Brfalse, lbl);
            }
        }
Пример #2
0
 internal static Type IsLiteral(AST ast)
 {
     if (ast != null)
     {
         Type type = ast.GetType();
         // FIXME: Add test for other literals (exclude StringLiteral)
         if (type == typeof(ArrayLiteral))
         {
             return(type);
         }
     }
     return(null);
 }
Пример #3
0
        internal static void fall_false(EmitContext ec, AST ast, Label lbl)
        {
            Type type = ast.GetType();

            if (type == typeof(Expression))
            {
                Expression exp = ast as Expression;

                if (exp.Size > 1)
                {
                    exp.Emit(ec);
                }

                AST last_exp = (AST)exp.exprs [exp.exprs.Count - 1];

                if (last_exp is Relational)
                {
                    ff_emit_relational(ec, last_exp, lbl);
                }
                else if (last_exp is Binary)
                {
                    ff_binary_recursion(ec, last_exp, lbl);
                }
                else if (last_exp is Identifier || last_exp is BooleanConstant)
                {
                    emit_default_case(ec, last_exp, OpCodes.Brtrue, lbl);
                }
                else if (last_exp is Equality)
                {
                    ff_emit_equality_cond(ec, last_exp, lbl);
                }
                else
                {
                    Console.WriteLine("WARNING: fall_false, last_exp.GetType () == {0}, {1}", last_exp, ast.Location.LineNumber);
                }
            }
            else if (type == typeof(Binary))
            {
                ff_binary_recursion(ec, ast, lbl);
            }
            else if (type == typeof(Relational))
            {
                ff_emit_relational(ec, ast, lbl);
            }
            else
            {
                emit_default_case(ec, ast, OpCodes.Brtrue, lbl);
            }
        }
Пример #4
0
		bool IsLoop (AST ast)
		{
			Type t = ast.GetType ();
			return t == typeof (For) || t == typeof (While) || t == typeof (DoWhile) || t == typeof (ForIn);
		}
Пример #5
0
		internal static Type IsLiteral (AST ast)
		{
			if (ast != null) {
				Type type = ast.GetType ();
				// FIXME: Add test for other literals (exclude StringLiteral)
				if (type == typeof (ArrayLiteral))
					return type;
			}
			return null;
		}
Пример #6
0
        internal static void fall_true(EmitContext ec, AST ast, Label lbl)
        {
            Type type = ast.GetType ();

            if (type == typeof (Expression)) {
                Expression exp = ast as Expression;
                AST last_exp = (AST) exp.exprs [exp.exprs.Count - 1];
                if (exp.exprs.Count >= 2)
                    exp.Emit (ec);
                fall_true (ec, last_exp, lbl);
            } else if (type == typeof (Binary))
                ft_binary_recursion (ec, ast, lbl);
            else if (type == typeof (Equality) || type == typeof (StrictEquality))
                ft_emit_equality (ec, ast, lbl);
            else if (type == typeof (Relational))
                ft_emit_relational (ec, (Relational) ast, lbl);
            else
                emit_default_case (ec, ast, OpCodes.Brfalse, lbl);
        }
Пример #7
0
        internal static void fall_false(EmitContext ec, AST ast, Label lbl)
        {
            Type type = ast.GetType ();

            if (type == typeof (Expression)) {
                Expression exp = ast as Expression;

                if (exp.Size > 1)
                    exp.Emit (ec);

                AST last_exp = (AST) exp.exprs [exp.exprs.Count - 1];

                if (last_exp is Relational)
                    ff_emit_relational (ec, last_exp, lbl);
                else if (last_exp is Binary)
                    ff_binary_recursion (ec, last_exp, lbl);
                else if (last_exp is Identifier || last_exp is BooleanConstant)
                    emit_default_case (ec, last_exp, OpCodes.Brtrue, lbl);
             				else if (last_exp is Equality)
                    ff_emit_equality_cond (ec, last_exp, lbl);
                else {
                    Console.WriteLine ("WARNING: fall_false, last_exp.GetType () == {0}, {1}", last_exp, ast.Location.LineNumber);
                }
            } else if (type == typeof (Binary))
                ff_binary_recursion (ec, ast, lbl);
            else if (type == typeof (Relational))
                ff_emit_relational (ec, ast, lbl);
            else
                emit_default_case (ec, ast, OpCodes.Brtrue, lbl);
        }
Пример #8
0
        bool IsLoop(AST ast)
        {
            Type t = ast.GetType();

            return(t == typeof(For) || t == typeof(While) || t == typeof(DoWhile) || t == typeof(ForIn));
        }