示例#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
文件: Php54Array.cs 项目: soywiz/nphp
 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
文件: Php54Array.cs 项目: soywiz/nphp
 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
文件: Php54Array.cs 项目: soywiz/nphp
 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
文件: Php54Array.cs 项目: soywiz/nphp
        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
文件: Php54Scope.cs 项目: soywiz/nphp
 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
文件: Php54Scope.cs 项目: soywiz/nphp
 public void SetReturnValueObject(object Value)
 {
     ReturnValue = Php54Var.FromObject(Value);
 }