Ejemplo n.º 1
0
        public override IPhpStatement Simplify(IPhpSimplifier s)
        {
            var initVariables = InitVariables == null
                ? null
                : InitVariables.Select(u => s.Simplify(u)).Cast <PhpAssignExpression>().ToArray();
            var condition    = s.Simplify(Condition);
            var statement    = s.Simplify(Statement);
            var incrementors = Incrementors == null
                ? null
                : Incrementors.Select(u => s.Simplify(u)).ToArray();
            var theSame = EqualCode(condition, Condition) && EqualCode(statement, Statement) &&
                          EqualCode_Array(initVariables, InitVariables) &&
                          EqualCode_Array(incrementors, Incrementors);

            if (theSame)
            {
                return(this);
            }
            return(new PhpForStatement(initVariables, condition, statement, incrementors));
        }
Ejemplo n.º 2
0
        public void InitializeIncrementors()
        {
            try
            {
                Incrementors.AddFrom(Assembly.GetExecutingAssembly());

                // ReSharper disable once AssignNullToNotNullAttribute
                var files = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                               "*.Incrementor.dll");

                foreach (var file in files)
                {
                    Logger.Write($"Loading incrementors from \"{file}\".", LogLevel.Debug);

                    var asm = Assembly.LoadFrom(file);

                    Incrementors.AddFrom(asm);
                }
            }
            catch (Exception ex)
            {
                Logger.Write($"Exception occured while initializing incrementors.\n{ex}", LogLevel.Error);
            }
        }
Ejemplo n.º 3
0
 protected override string InnerTranslate()
 {
     return($@"for({Declaration?.Translate()};{Condition?.Translate()};{Incrementors?.Translate()})
         {Statement.Translate()}");
 }