Пример #1
0
        public static void Assign(Php54Var Left, Php54Var Right)
        {
            if (Left.IsReference)
            {
                Assign(Left.ReferencedValue, Right);
                return;
            }

            if (Right.IsReference)
            {
                Left.ReferencedDynamicValue = Right;
                Left.ThisType = TypeEnum.Reference;
                return;
            }

            switch (Right.ReferencedType)
            {
                case TypeEnum.Array:
                    Left.ThisType = Right.ReferencedType;
                    Left.ReferencedDynamicValue = Right.ArrayValue.Clone();
                    break;
                default:
                    Left.ThisType = Right.ReferencedType;
                    Left.ReferencedDynamicValue = Right.ReferencedDynamicValue;
                    break;
            }
        }
Пример #2
0
 public void AddElement(Php54Var Value)
 {
     var KeyInt = LastNumericIndex++;
     var Key = Php54Var.FromInt(KeyInt);
     Keys.Add(Key);
     Values.Add(Value);
     KeyIndices[Key] = Keys.Count - 1;
 }
Пример #3
0
        public static void Eval(Php54Scope Scope, Php54Var Variable)
        {
            IPhp54Function EvalFunction;
            try
            {
                 EvalFunction = Scope.Runtime.CreateMethodFromPhpCode(Variable.StringValue, "eval()");
            }
            catch (Exception Exception)
            {
                Console.WriteLine(Exception);
                return;
            }

            EvalFunction.Execute(Scope);
        }
Пример #4
0
 public void AddPair(Php54Var Key, Php54Var Value)
 {
     UpdateLastNumericIndex(Key);
     // Add new
     if (!KeyIndices.ContainsKey(Key))
     {
         Keys.Add(Key);
         Values.Add(Value);
         KeyIndices[Key] = Keys.Count - 1;
     }
     // Update
     else
     {
         int Index = KeyIndices[Key];
         Values[Index] = Value;
     }
 }
Пример #5
0
 public static Php54Var Add(Php54Var Left, Php54Var Right)
 {
     var CombinedType = CombineTypes(Left.ReferencedType, Right.ReferencedType);
     switch (CombinedType)
     {
         case TypeEnum.Int:
             try
             {
                 checked
                 {
                     int Result = Left.IntegerValue + Right.IntegerValue;
                     return new Php54Var(Result, TypeEnum.Int);
                 }
             }
             catch (OverflowException)
             {
                 return new Php54Var(Left.DoubleValue + Right.DoubleValue, TypeEnum.Double);
             }
         default:
             {
                 return new Php54Var(Left.DoubleValue + Right.DoubleValue, TypeEnum.Double);
             }
     }
 }
Пример #6
0
 public static void AssignSub(Php54Var Left, Php54Var Right)
 {
     //Left.DynamicValue += Right.DynamicValue;
     Assign(Left, Sub(Left, Right));
 }
Пример #7
0
 public static bool CompareLessThan(Php54Var Left, Php54Var Right)
 {
     return Left.NumericValue < Right.NumericValue;
 }
Пример #8
0
 public static Php54Var UnarySub(Php54Var Right)
 {
     return new Php54Var(-Right.NumericValue, Right.ReferencedType);
 }
Пример #9
0
 public static Php54Var UnarySilence(Php54Var Right)
 {
     return Right;
 }
Пример #10
0
 public static bool CompareNotEquals(Php54Var Left, Php54Var Right)
 {
     return !CompareEquals(Left, Right);
 }
Пример #11
0
 public static bool CompareGreaterOrEqualThan(Php54Var Left, Php54Var Right)
 {
     return Left.NumericValue >= Right.NumericValue;
 }
Пример #12
0
 public static Php54Var UnaryAdd(Php54Var Right)
 {
     //return new Php54Var(+Right.DynamicValue, Right.Type);
     return Right;
 }
Пример #13
0
 public static Php54Var UnaryBitNot(Php54Var Left)
 {
     return new Php54Var(~Left.IntegerValue, TypeEnum.Int);
 }
Пример #14
0
 public static bool LogicalOr(Php54Var Left, Php54Var Right)
 {
     return Left.BooleanValue || Right.BooleanValue;
 }
Пример #15
0
 public static Php54Var Sub(Php54Var Left, Php54Var Right)
 {
     return new Php54Var(Left.NumericValue - Right.NumericValue, CombineTypes(Left.ReferencedType, Right.ReferencedType));
 }
Пример #16
0
 public static bool LogicalAnd(Php54Var Left, Php54Var Right)
 {
     return Left.BooleanValue && Right.BooleanValue;
 }
Пример #17
0
 public static Php54Var Concat(Php54Var Left, Php54Var Right)
 {
     return new Php54Var(Left.StringValue + Right.StringValue, CombineTypes(Left.ReferencedType, Right.ReferencedType));
 }
Пример #18
0
 public static bool CompareStrictNotEquals(Php54Var Left, Php54Var Right)
 {
     //if (Left.ReferencedType != Right.ReferencedType) return false;
     return !(CompareStrictEquals(Left, Right));
 }
Пример #19
0
 public static Php54Var BitOr(Php54Var Left, Php54Var Right)
 {
     return new Php54Var(Left.IntegerValue | Right.IntegerValue, TypeEnum.Int);
 }
Пример #20
0
 public Php54Var GetElementByKey(Php54Var Key)
 {
     return Values[KeyIndices[Key]];
 }
Пример #21
0
 public static bool CompareEquals(Php54Var Left, Php54Var Right)
 {
     switch (CombineTypes(Left.ReferencedType, Right.ReferencedType))
     {
         case TypeEnum.Int: return Left.IntegerValue == Right.IntegerValue;
         case TypeEnum.Double: return Left.DoubleValue == Right.DoubleValue;
         default: return Left.StringValue == Right.StringValue;
     }
 }
Пример #22
0
 public static void Echo(Php54Scope Scope, Php54Var Variable)
 {
     //Scope.Php54Runtime.TextWriter.Write(Variable);
     Console.Out.Write(Variable);
 }
Пример #23
0
        private void UpdateLastNumericIndex(Php54Var Key)
        {
            if ((Key.ReferencedType != Php54Var.TypeEnum.Int) && (Key.ReferencedType != Php54Var.TypeEnum.String)) throw (new InvalidOperationException("Keys must be integers or strings only"));

            if ((Key.ReferencedType == Php54Var.TypeEnum.Int) || (Php54Utils.IsCompletelyNumeric(Key.StringValue)))
            {
                var IntKey = Key.IntegerValue;
                if (IntKey > LastNumericIndex)
                {
                    LastNumericIndex = IntKey + 1;
                    PureArray = false;
                }
                else
                {
                    //PureArray = PureArray; // not changed
                }
            }
            else
            {
                PureArray = false;
            }
        }
Пример #24
0
 public void SetArgument(int Index, Php54Var Value)
 {
     Arguments[Index] = Value;
 }
Пример #25
0
 public static Php54Var UnaryLogicNot(Php54Var Left)
 {
     return new Php54Var(!Left.BooleanValue, TypeEnum.Bool);
 }
Пример #26
0
 public static bool CompareLessThan(Php54Var Left, int Right)
 {
     return Left.IntegerValue < Right;
 }
Пример #27
0
 public void Reset()
 {
     this.ConstantScope = new Php54Scope(this);
     this.GlobalScope = new Php54Scope(this);
     this.ShutdownFunction = null;
     OutputFunctions.__ob_reset();
 }
Пример #28
0
 public static Php54Var UnaryPostIncrement(Php54Var Left, int Count)
 {
     var Old = Left.NumericValue;
     Left.ReferencedDynamicValue = Old + Count;
     return new Php54Var(Old, Left.ReferencedType);
 }
Пример #29
0
 public static Php54Var UnaryPreIncrement(Php54Var Left, int Count)
 {
     Left.ReferencedDynamicValue = Left.NumericValue + Count;
     return new Php54Var(Left.ReferencedDynamicValue, Left.ReferencedType);
 }
Пример #30
0
 public void SetReturnValueObject(object Value)
 {
     ReturnValue = Php54Var.FromObject(Value);
 }