public RETURN(Expression expr, int line, int column) : base(line, column) { Expr = expr; }
public IS_NOT_IDENTICAL(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public void StoreToObjectOperator(OBJECT_OPERATOR oo, Expression value) { // warn if left part is a function call if (oo.Expr1 is FUNCTION_CALL) { FUNCTION_CALL fc = (FUNCTION_CALL)oo.Expr1; Report.Warn(404, fc.FunctionName, fc.Line, fc.Column); if (ObjectOperatorInProgress) { IlGen.Emit(OpCodes.Pop); ObjectOperatorInProgress = false; } return; } // process left part ObjectOperatorInProgress = true; // local variable if (oo.Expr1 is VARIABLE) { VARIABLE var = (VARIABLE)oo.Expr1; // handle $this-> if (var.Name == "$this") { ProcessingObjectThisWhenStoring = true; // if this is a static context, load object from which this static context was called if (FD.Modifiers.Contains(Modifiers.STATIC)) { Report.Warn(502, var.Line, var.Column); IlGen.Emit(OpCodes.Ldsfld, PHPRuntimeCore.GetField("ThisForStaticContext")); } // otherwise load current object else IlGen.Emit(OpCodes.Ldarg_0); if (var.Offset != null) Report.Warn(401, CD.Name, var.Offset.Line, var.Offset.Column); } // some variable else if (var.Name.StartsWith("$")) { ProcessingObjectThisWhenStoring = false; Visit(var); } // class member else { // if processing a class member of $this (of a non-static context), load directly if (ProcessingObjectThisWhenStoring && !FD.Modifiers.Contains(Modifiers.STATIC)) LoadFromClassMemberOfThis(var.Name, var.Line, var.Column); // else load at runtime by reflection else LoadFromClassMemberOfAnotherObject(var.Name); ProcessingObjectThisWhenStoring = false; // process offset, if available if (var.Offset != null) { // this is an array if (var.Offset.Kind == OFFSET.SQUARE) { if (var.Offset.Value == null) IlGen.Emit(OpCodes.Ldnull); else Visit(var.Offset); IlGen.Emit(OpCodes.Ldc_I4, OFFSET.SQUARE); IlGen.Emit(OpCodes.Call, PHPRuntimeCore.GetMethod("Offset", new Type[] { typeof(object), typeof(object), typeof(int) })); } } } } // paamayim nekudotayim else if (oo.Expr1 is PAAMAYIM_NEKUDOTAYIM) { PAAMAYIM_NEKUDOTAYIM pn = (PAAMAYIM_NEKUDOTAYIM)oo.Expr1; LoadFromPaamayimNekudotayim(pn); } // process right part if (oo.Expr2 is OBJECT_OPERATOR) StoreToObjectOperator((OBJECT_OPERATOR)oo.Expr2, value); else if (oo.Expr2 is VARIABLE) { VARIABLE var2 = (VARIABLE)oo.Expr2; // no offset available, so store to class member if (var2.Offset == null) { Visit(value); // if processing a class member of $this, store directly if (ProcessingObjectThisWhenStoring) StoreToClassMemberOfThis(var2.Name, var2.Line, var2.Column); // else store at runtime by reflection else StoreToClassMemberOfAnotherObject(var2.Name); } // array offset available, so store to specified place else if (var2.Offset.Kind == OFFSET.SQUARE) { IlGen.Emit(OpCodes.Dup); IlGen.Emit(OpCodes.Dup); // if processing a class member of $this, load directly if (ProcessingObjectThisWhenStoring) LoadFromClassMemberOfThis(var2.Name, var2.Line, var2.Column); // else load at runtime by reflection else LoadFromClassMemberOfAnotherObject(var2.Name); // if array loaded is null, create a new one and store Label skip = IlGen.DefineLabel(); Label join = IlGen.DefineLabel(); IlGen.Emit(OpCodes.Brtrue, skip); IlGen.Emit(OpCodes.Newobj, PHPArray.GetConstructor(Type.EmptyTypes)); // if processing a class member of $this, store directly if (ProcessingObjectThisWhenStoring) StoreToClassMemberOfThis(var2.Name, var2.Line, var2.Column); // else store at runtime by reflection else StoreToClassMemberOfAnotherObject(var2.Name); IlGen.Emit(OpCodes.Br, join); IlGen.MarkLabel(skip); IlGen.Emit(OpCodes.Pop); IlGen.MarkLabel(join); // if processing a class member of $this, load directly if (ProcessingObjectThisWhenStoring) LoadFromClassMemberOfThis(var2.Name, var2.Line, var2.Column); // else load at runtime by reflection else LoadFromClassMemberOfAnotherObject(var2.Name); // convert to Array (in case the variable was unset) IlGen.Emit(OpCodes.Callvirt, PHPRuntimeConvert.GetMethod("ToArray", new Type[] { typeof(object) })); // if no offset available, append without user defined key if (var2.Offset.Value == null) { Visit(value); IlGen.Emit(OpCodes.Callvirt, PHPArray.GetMethod("Append", new Type[] { typeof(object) })); } // otherwise use user defined key else { Visit(var2.Offset.Value); Visit(value); IlGen.Emit(OpCodes.Callvirt, PHPArray.GetMethod("Append", new Type[] { typeof(object), typeof(object) })); } } ObjectOperatorInProgress = false; } else if (oo.Expr2 is FUNCTION_CALL) { FUNCTION_CALL fc = (FUNCTION_CALL)oo.Expr2; Report.Warn(403, fc.FunctionName, fc.Line, fc.Column); if (ObjectOperatorInProgress) { IlGen.Emit(OpCodes.Pop); ObjectOperatorInProgress = false; } return; } }
public INC(Expression expr, int kind, int line, int column) : base(expr, line, column) { Kind = kind; }
public INT_CAST(Expression expr, int line, int column) : base(expr, line, column) { }
public ARRAY_PAIR(Expression key, Expression value, int line, int column) : base(line, column) { Key = key; Value = value; }
public IF(Expression expr, Statement stmt, ArrayList elseifList, Statement elseStmt, int line, int column) : base(line, column) { Expr = expr; Stmt = stmt; ElseifList = elseifList; ElseStmt = elseStmt; }
public BOOLEAN_OR(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public BREAK(Expression expr, int line, int column) : base(line, column) { Expr = expr; }
public UnaryExpression(Expression expr, int line, int column) : base(line, column) { Expr = expr; }
public BOOLEAN_NOT(Expression expr, int line, int column) : base(expr, line, column) { }
public THROW(Expression expr, int line, int column) : base(line, column) { Expr = expr; }
public TernaryExpression(Expression expr1, Expression expr2, Expression expr3, int line, int column) : base(line, column) { Expr1 = expr1; Expr2 = expr2; Expr3 = expr3; }
public SWITCH(Expression expr, ArrayList switchCaseList, int line, int column) : base(line, column) { Expr = expr; SwitchCaseList = switchCaseList; }
public EXPRESSION_AS_STATEMENT(Expression expr, int line, int column) : base(line, column) { Expr = expr; }
public CLONE(Expression expr, int line, int column) : base(expr, line, column) { }
public FOREACH(Expression array, Expression key, Expression value, Statement stmt, int line, int column) : base(line, column) { Array = array; Key = key; Value = value; Stmt = stmt; }
public CONCAT_EQUAL(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public GREATER(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public CONTINUE(Expression expr, int line, int column) : base(line, column) { Expr = expr; }
public IF_EXPR(Expression expr1, Expression expr2, Expression expr3, int line, int column) : base(expr1, expr2, expr3, line, column) { }
public DO(Statement stmt, Expression expr, int line, int column) : base(line, column) { Stmt = stmt; Expr = expr; }
public INSTANCEOF(Expression expr, string type, int line, int column) : base(line, column) { Expr = expr; Type = type; }
public ELSEIF(Expression expr, Statement stmt, int line, int column) : base(line, column) { Expr = expr; Stmt = stmt; }
public IS_LOWER_OR_EQUAL(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public EQUALS(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public LOGICAL_AND(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public EXIT(Expression expr, int line, int column) : base(expr, line, column) { }
public void StoreToPaamayimNekudotayim(PAAMAYIM_NEKUDOTAYIM pn, Expression value) { // handle self:: and parent:: if (pn.Type == "self") pn.Type = CD.Name; else if (pn.Type == "parent") { if (CD.Extends == null) Report.Error(503, pn.Line, pn.Column); pn.Type = CD.Extends; } // process right part if (pn.Expr is VARIABLE) { VARIABLE var = (VARIABLE)pn.Expr; string classMemberName = (var.Name.StartsWith("$")) ? var.Name.Remove(0, 1) : var.Name; // no offset available, so store to class member if (var.Offset == null) { Visit(value); // store StoreToStaticClassMember(pn.Type, classMemberName, var.Line, var.Column); } // array offset available, so store to specified place else if (var.Offset.Kind == OFFSET.SQUARE) { // load LoadFromStaticClassMember(pn.Type, classMemberName, var.Line, var.Column); // if array loaded is null, create a new one and store Label skip = IlGen.DefineLabel(); IlGen.Emit(OpCodes.Brtrue, skip); IlGen.Emit(OpCodes.Newobj, PHPArray.GetConstructor(Type.EmptyTypes)); // store StoreToStaticClassMember(pn.Type, classMemberName, var.Line, var.Column); IlGen.MarkLabel(skip); // load LoadFromStaticClassMember(pn.Type, classMemberName, var.Line, var.Column); // convert to Array (in case the variable was unset) IlGen.Emit(OpCodes.Callvirt, PHPRuntimeConvert.GetMethod("ToArray", new Type[] { typeof(object) })); // if no offset available, append without user defined key if (var.Offset.Value == null) { Visit(value); IlGen.Emit(OpCodes.Callvirt, PHPArray.GetMethod("Append", new Type[] { typeof(object) })); } // otherwise use user defined key else { Visit(var.Offset.Value); Visit(value); IlGen.Emit(OpCodes.Callvirt, PHPArray.GetMethod("Append", new Type[] { typeof(object), typeof(object) })); } } } else if (pn.Expr is FUNCTION_CALL) { Report.Error(408, pn.Line, pn.Column); return; } }
public BinaryExpression(Expression expr1, Expression expr2, int line, int column) : base(line, column) { Expr1 = expr1; Expr2 = expr2; }