Esempio n. 1
0
 public ArrayStatement(TypeDescriptor type, EvaluationStatement length, EvaluationStatement[] elements, StatementInfo info)
 {
     Info     = info;
     Type     = type;
     Length   = length;
     Elements = elements;
 }
Esempio n. 2
0
        public IfElseStatement(ConditionalBlockStatement mainIf, ConditionalBlockStatement[] elseIfs,
                               StatementInfo info)
        {
            MainIf  = mainIf;
            ElseIfs = elseIfs;
            Info    = info;

            var children = new List <IStatement>(elseIfs.Length + 2);
            var branches = new List <IStatement>(elseIfs.Length + 2);

            if (mainIf != null)
            {
                children.Add(mainIf);
                branches.Add(mainIf.Statement);
            }

            foreach (var child in elseIfs)
            {
                if (child != null)
                {
                    children.Add(child);
                    branches.Add(child.Statement);
                }
            }

            TraversableChildren = children.ToArray();
            Branches            = branches.ToArray();
        }
 public static BitwiseEvaluationStatement CreateNot(BitwiseNotOperator op, EvaluationStatement operand,
                                                    StatementInfo info, IStatement parentStatement = null)
 {
     return(new BitwiseEvaluationStatement(null, op, operand, info)
     {
         ParentStatement = parentStatement
     });
 }
Esempio n. 4
0
        public IfElseStatement(ConditionalBlockStatement mainIf, StatementInfo info)
        {
            MainIf = mainIf;
            Info   = info;

            TraversableChildren = StatementHelpers.CreateChildren(mainIf);
            Branches            = new[] { mainIf.Statement };
        }
Esempio n. 5
0
 public static void AssertAssignableFrom(Context context, Scope scope, TypeDescriptor destination,
                                         TypeDescriptor source, StatementInfo info)
 {
     if (!IsAssignableFrom(context, scope, destination, source))
     {
         throw new TypeMismatchCompilerException(source, destination, info);
     }
 }
Esempio n. 6
0
        public TypeCastStatement(TypeDescriptor typeDescriptor, EvaluationStatement target, StatementInfo info, IStatement parentStatement)
        {
            TypeDescriptor = typeDescriptor;
            Target         = target;
            Info           = info;

            ParentStatement = parentStatement;
        }
        public ConstantValueStatement(TypeDescriptor typeDescriptor, string value,
                                      StatementInfo info)
        {
            TypeDescriptor = typeDescriptor;
            Value          = value;
            Info           = info;

            TraversableChildren = new IStatement[0];
        }
Esempio n. 8
0
        public EchoStatement(
            EvaluationStatement[] parameters, StatementInfo info)
        {
            Parameters = parameters;
            Info       = info;

            // ReSharper disable once CoVariantArrayConversion
            TraversableChildren = StatementHelpers.CreateChildren(parameters);
        }
        public SwitchCaseStatement(EvaluationStatement switchTarget, ConditionalBlockStatement[] cases, StatementInfo info)
        {
            SwitchTarget = switchTarget;
            Cases        = cases;
            Info         = info;

            TraversableChildren = StatementHelpers.CreateChildren(new IStatement[] { switchTarget }.Union(cases).ToArray());
            Branches            = cases.Select(x => x.Statement).ToArray();
        }
Esempio n. 10
0
        public DelegateStatement(string name, TypeDescriptor returnTypeDescriptor, FunctionParameterDefinitionStatement[] parameters,
                                 StatementInfo info)
        {
            Name = name;
            ReturnTypeDescriptor = returnTypeDescriptor;
            Parameters           = parameters;
            Info = info;

            TraversableChildren = StatementHelpers.EmptyStatements;
        }
Esempio n. 11
0
 public VariableDefinitionStatement(
     TypeDescriptor typeDescriptor,
     string name,
     bool isConstant,
     EvaluationStatement value,
     StatementInfo info)
     : base(typeDescriptor, name, value, value != null, info)
 {
     IsConstant = isConstant;
 }
        public BitwiseEvaluationStatement(EvaluationStatement left, BitwiseOperator @operator,
                                          EvaluationStatement right, StatementInfo info, IStatement parentStatement = null)
        {
            Left            = left;
            Operator        = @operator;
            Right           = right;
            Info            = info;
            ParentStatement = parentStatement;

            TraversableChildren = StatementHelpers.CreateChildren(left, @operator, right);
        }
Esempio n. 13
0
        public DefinitionStatement(TypeDescriptor typeDescriptor, string name, EvaluationStatement defaultValue,
                                   bool hasDefaultValue, StatementInfo info)
        {
            TypeDescriptor  = typeDescriptor;
            Name            = name;
            DefaultValue    = defaultValue;
            HasDefaultValue = hasDefaultValue;
            Info            = info;

            TraversableChildren = StatementHelpers.CreateChildren(defaultValue);
        }
Esempio n. 14
0
        public IfElseStatement(ConditionalBlockStatement mainIf, IStatement @else, StatementInfo info)
        {
            MainIf = mainIf;
            Else   = @else;
            Info   = info;

            TraversableChildren = StatementHelpers.CreateChildren(mainIf, @else);
            Branches            = mainIf?.Statement != null
                ? new[] { mainIf.Statement, @else }
                : new[] { @else };
        }
Esempio n. 15
0
        public ArithmeticEvaluationStatement(EvaluationStatement left, ArithmeticOperator @operator,
                                             EvaluationStatement right, StatementInfo info, IStatement parentStatement = null)
        {
            CanBeEmbedded   = false;
            Left            = left;
            Operator        = @operator;
            Right           = right;
            Info            = info;
            ParentStatement = parentStatement;

            TraversableChildren = StatementHelpers.CreateChildren(left, @operator, right);
        }
Esempio n. 16
0
        public FunctionCallStatement(string className, string functionName, TypeDescriptor typeDescriptor,
                                     EvaluationStatement[] parameters, StatementInfo info, IStatement parentStatement = null)
        {
            ClassName       = className;
            FunctionName    = functionName;
            Parameters      = parameters;
            Info            = info;
            TypeDescriptor  = typeDescriptor;
            ParentStatement = parentStatement;

            // ReSharper disable once CoVariantArrayConversion
            TraversableChildren = StatementHelpers.CreateChildren(parameters);
        }
Esempio n. 17
0
        public FunctionStatement(TypeDescriptor typeDescriptor, string name,
                                 FunctionParameterDefinitionStatement[] parameters, IStatement statement, StatementInfo info)
        {
            TypeDescriptor = typeDescriptor;
            Name           = name;
            Statement      = statement;
            Info           = info;
            Parameters     = parameters;

            if (parameters != null)
            {
                TraversableChildren =
                    StatementHelpers.CreateChildren(new IStatement[] { statement }.Union(parameters).ToArray());
            }
            else
            {
                TraversableChildren =
                    StatementHelpers.CreateChildren(statement);
            }
        }
Esempio n. 18
0
 public static ArithmeticEvaluationStatement CreatePrefixDecrement(DecrementOperator op,
                                                                   EvaluationStatement operand, StatementInfo info, IStatement parentStatement = null)
 {
     return(new ArithmeticEvaluationStatement(true, null, op, operand, info)
     {
         ParentStatement = parentStatement
     });
 }
Esempio n. 19
0
        public ForStatement(IStatement[] preLoopAssignment, EvaluationStatement condition, IStatement[] afterLoopEvaluations, IStatement statement, StatementInfo info)
            : base(condition, statement, info)
        {
            PreLoopAssignment    = preLoopAssignment;
            AfterLoopEvaluations = afterLoopEvaluations;

            var children = new List <IStatement>();

            if (preLoopAssignment != null)
            {
                children.AddRange(preLoopAssignment);
            }
            if (condition != null)
            {
                children.Add(condition);
            }
            if (afterLoopEvaluations != null)
            {
                children.AddRange(afterLoopEvaluations);
            }
            if (statement != null)
            {
                children.Add(statement);
            }

            TraversableChildren = children.ToArray();
        }
Esempio n. 20
0
 public TypeCastStatement(TypeDescriptor typeDescriptor, EvaluationStatement target, StatementInfo info)
 {
     TypeDescriptor = typeDescriptor;
     Target         = target;
     Info           = info;
 }
 public FunctionParameterDefinitionStatement(
     TypeDescriptor typeDescriptor, string name, ConstantValueStatement defaultValue, StatementInfo info, bool dynamicType)
     : base(typeDescriptor, name, defaultValue, defaultValue != null, info)
 {
     DynamicType = dynamicType;
 }
Esempio n. 22
0
 public static ArithmeticEvaluationStatement CreatePostfix(ArithmeticOperator op,
                                                           EvaluationStatement operand, StatementInfo info, IStatement parentStatement = null)
 {
     return(new ArithmeticEvaluationStatement(operand, op, null, info)
     {
         ParentStatement = parentStatement
     });
 }
Esempio n. 23
0
 public static ArithmeticEvaluationStatement CreateNegate(NegativeNumberOperator op,
                                                          EvaluationStatement operand, StatementInfo info, IStatement parentStatement = null)
 {
     return(new ArithmeticEvaluationStatement(null, op, operand, info)
     {
         ParentStatement = parentStatement
     });
 }