示例#1
0
文件: AST.cs 项目: Notulp/php4mono
 public RETURN(Expression expr, int line, int column)
     : base(line, column)
 {
     Expr = expr;
 }
示例#2
0
文件: AST.cs 项目: Notulp/php4mono
 public IS_NOT_IDENTICAL(Expression expr1, Expression expr2, int line, int column)
     : base(expr1, expr2, line, column)
 {
 }
示例#3
0
		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;
			}
		}
示例#4
0
文件: AST.cs 项目: Notulp/php4mono
 public INC(Expression expr, int kind, int line, int column)
     : base(expr, line, column)
 {
     Kind = kind;
 }
示例#5
0
文件: AST.cs 项目: Notulp/php4mono
 public INT_CAST(Expression expr, int line, int column)
     : base(expr, line, column)
 {
 }
示例#6
0
文件: AST.cs 项目: Notulp/php4mono
 public ARRAY_PAIR(Expression key, Expression value, int line, int column)
     : base(line, column)
 {
     Key = key;
     Value = value;
 }
示例#7
0
文件: AST.cs 项目: Notulp/php4mono
 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;
 }
示例#8
0
文件: AST.cs 项目: Notulp/php4mono
 public BOOLEAN_OR(Expression expr1, Expression expr2, int line, int column)
     : base(expr1, expr2, line, column)
 {
 }
示例#9
0
文件: AST.cs 项目: Notulp/php4mono
 public BREAK(Expression expr, int line, int column)
     : base(line, column)
 {
     Expr = expr;
 }
示例#10
0
文件: AST.cs 项目: Notulp/php4mono
 public UnaryExpression(Expression expr, int line, int column)
     : base(line, column)
 {
     Expr = expr;
 }
示例#11
0
文件: AST.cs 项目: Notulp/php4mono
 public BOOLEAN_NOT(Expression expr, int line, int column)
     : base(expr, line, column)
 {
 }
示例#12
0
文件: AST.cs 项目: Notulp/php4mono
 public THROW(Expression expr, int line, int column)
     : base(line, column)
 {
     Expr = expr;
 }
示例#13
0
文件: AST.cs 项目: Notulp/php4mono
 public TernaryExpression(Expression expr1, Expression expr2, Expression expr3, int line, int column)
     : base(line, column)
 {
     Expr1 = expr1;
     Expr2 = expr2;
     Expr3 = expr3;
 }
示例#14
0
文件: AST.cs 项目: Notulp/php4mono
 public SWITCH(Expression expr, ArrayList switchCaseList, int line, int column)
     : base(line, column)
 {
     Expr = expr;
     SwitchCaseList = switchCaseList;
 }
示例#15
0
文件: AST.cs 项目: Notulp/php4mono
 public EXPRESSION_AS_STATEMENT(Expression expr, int line, int column)
     : base(line, column)
 {
     Expr = expr;
 }
示例#16
0
文件: AST.cs 项目: Notulp/php4mono
 public CLONE(Expression expr, int line, int column)
     : base(expr, line, column)
 {
 }
示例#17
0
文件: AST.cs 项目: Notulp/php4mono
 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;
 }
示例#18
0
文件: AST.cs 项目: Notulp/php4mono
 public CONCAT_EQUAL(Expression expr1, Expression expr2, int line, int column)
     : base(expr1, expr2, line, column)
 {
 }
示例#19
0
文件: AST.cs 项目: Notulp/php4mono
 public GREATER(Expression expr1, Expression expr2, int line, int column)
     : base(expr1, expr2, line, column)
 {
 }
示例#20
0
文件: AST.cs 项目: Notulp/php4mono
 public CONTINUE(Expression expr, int line, int column)
     : base(line, column)
 {
     Expr = expr;
 }
示例#21
0
文件: AST.cs 项目: Notulp/php4mono
 public IF_EXPR(Expression expr1, Expression expr2, Expression expr3, int line, int column)
     : base(expr1, expr2, expr3, line, column)
 {
 }
示例#22
0
文件: AST.cs 项目: Notulp/php4mono
 public DO(Statement stmt, Expression expr, int line, int column)
     : base(line, column)
 {
     Stmt = stmt;
     Expr = expr;
 }
示例#23
0
文件: AST.cs 项目: Notulp/php4mono
 public INSTANCEOF(Expression expr, string type, int line, int column)
     : base(line, column)
 {
     Expr = expr;
     Type = type;
 }
示例#24
0
文件: AST.cs 项目: Notulp/php4mono
 public ELSEIF(Expression expr, Statement stmt, int line, int column)
     : base(line, column)
 {
     Expr = expr;
     Stmt = stmt;
 }
示例#25
0
文件: AST.cs 项目: Notulp/php4mono
 public IS_LOWER_OR_EQUAL(Expression expr1, Expression expr2, int line, int column)
     : base(expr1, expr2, line, column)
 {
 }
示例#26
0
文件: AST.cs 项目: Notulp/php4mono
 public EQUALS(Expression expr1, Expression expr2, int line, int column)
     : base(expr1, expr2, line, column)
 {
 }
示例#27
0
文件: AST.cs 项目: Notulp/php4mono
 public LOGICAL_AND(Expression expr1, Expression expr2, int line, int column)
     : base(expr1, expr2, line, column)
 {
 }
示例#28
0
文件: AST.cs 项目: Notulp/php4mono
 public EXIT(Expression expr, int line, int column)
     : base(expr, line, column)
 {
 }
示例#29
0
		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;
			}
		}
示例#30
0
文件: AST.cs 项目: Notulp/php4mono
 public BinaryExpression(Expression expr1, Expression expr2, int line, int column)
     : base(line, column)
 {
     Expr1 = expr1;
     Expr2 = expr2;
 }