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; } }
public void AddElement(Php54Var Value) { var KeyInt = LastNumericIndex++; var Key = Php54Var.FromInt(KeyInt); Keys.Add(Key); Values.Add(Value); KeyIndices[Key] = Keys.Count - 1; }
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); }
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; } }
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); } } }
public static void AssignSub(Php54Var Left, Php54Var Right) { //Left.DynamicValue += Right.DynamicValue; Assign(Left, Sub(Left, Right)); }
public static bool CompareLessThan(Php54Var Left, Php54Var Right) { return Left.NumericValue < Right.NumericValue; }
public static Php54Var UnarySub(Php54Var Right) { return new Php54Var(-Right.NumericValue, Right.ReferencedType); }
public static Php54Var UnarySilence(Php54Var Right) { return Right; }
public static bool CompareNotEquals(Php54Var Left, Php54Var Right) { return !CompareEquals(Left, Right); }
public static bool CompareGreaterOrEqualThan(Php54Var Left, Php54Var Right) { return Left.NumericValue >= Right.NumericValue; }
public static Php54Var UnaryAdd(Php54Var Right) { //return new Php54Var(+Right.DynamicValue, Right.Type); return Right; }
public static Php54Var UnaryBitNot(Php54Var Left) { return new Php54Var(~Left.IntegerValue, TypeEnum.Int); }
public static bool LogicalOr(Php54Var Left, Php54Var Right) { return Left.BooleanValue || Right.BooleanValue; }
public static Php54Var Sub(Php54Var Left, Php54Var Right) { return new Php54Var(Left.NumericValue - Right.NumericValue, CombineTypes(Left.ReferencedType, Right.ReferencedType)); }
public static bool LogicalAnd(Php54Var Left, Php54Var Right) { return Left.BooleanValue && Right.BooleanValue; }
public static Php54Var Concat(Php54Var Left, Php54Var Right) { return new Php54Var(Left.StringValue + Right.StringValue, CombineTypes(Left.ReferencedType, Right.ReferencedType)); }
public static bool CompareStrictNotEquals(Php54Var Left, Php54Var Right) { //if (Left.ReferencedType != Right.ReferencedType) return false; return !(CompareStrictEquals(Left, Right)); }
public static Php54Var BitOr(Php54Var Left, Php54Var Right) { return new Php54Var(Left.IntegerValue | Right.IntegerValue, TypeEnum.Int); }
public Php54Var GetElementByKey(Php54Var Key) { return Values[KeyIndices[Key]]; }
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; } }
public static void Echo(Php54Scope Scope, Php54Var Variable) { //Scope.Php54Runtime.TextWriter.Write(Variable); Console.Out.Write(Variable); }
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; } }
public void SetArgument(int Index, Php54Var Value) { Arguments[Index] = Value; }
public static Php54Var UnaryLogicNot(Php54Var Left) { return new Php54Var(!Left.BooleanValue, TypeEnum.Bool); }
public static bool CompareLessThan(Php54Var Left, int Right) { return Left.IntegerValue < Right; }
public void Reset() { this.ConstantScope = new Php54Scope(this); this.GlobalScope = new Php54Scope(this); this.ShutdownFunction = null; OutputFunctions.__ob_reset(); }
public static Php54Var UnaryPostIncrement(Php54Var Left, int Count) { var Old = Left.NumericValue; Left.ReferencedDynamicValue = Old + Count; return new Php54Var(Old, Left.ReferencedType); }
public static Php54Var UnaryPreIncrement(Php54Var Left, int Count) { Left.ReferencedDynamicValue = Left.NumericValue + Count; return new Php54Var(Left.ReferencedDynamicValue, Left.ReferencedType); }
public void SetReturnValueObject(object Value) { ReturnValue = Php54Var.FromObject(Value); }