public UnaryExpression(Expression expr, int line, int column) : base(line, column) { this.expr = expr; }
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; // no offset available, so store to class member if (var.offset == null) { Visit(value); // determine value or reference semantis bool referenceSemantics = false; // if assigned expr is a reference if (value is REFERENCE) { REFERENCE r = (REFERENCE)value; // and a variable is called, it's reference semantics if (r.variable is VARIABLE) referenceSemantics = true; // and a function not returnung a reference is called, it's reference semantics if (r.variable is FUNCTION_CALL) { SymbolTableEntry entry = SymbolTable.getInstance().lookup(((FUNCTION_CALL)r.variable).function_name.ToLower(), SymbolTable.FUNCTION); FUNCTION_DECLARATION fd = (FUNCTION_DECLARATION)entry.node; if (fd.return_by_reference) referenceSemantics = true; } } if (!referenceSemantics) ilGen.Emit(OpCodes.Call, PHPCoreLang.GetMethod("Clone", new Type[] { PHPMixed })); // store StoreToStaticClassMember(pn.type, var.name, var.line, var.column); } // array offset available, so store to specified place else if (var.offset.kind == OFFSET.SQUARE) { // load LoadFromStaticClassMember(pn.type, var.name, var.line, var.column); // if array loaded is null, create a new one and store Label skip = ilGen.DefineLabel(); ilGen.Emit(OpCodes.Isinst, PHPNull); ilGen.Emit(OpCodes.Brfalse, skip); ilGen.Emit(OpCodes.Newobj, PHPArray.GetConstructor(Type.EmptyTypes)); // store StoreToStaticClassMember(pn.type, var.name, var.line, var.column); ilGen.MarkLabel(skip); // load LoadFromStaticClassMember(pn.type, var.name, var.line, var.column); // convert to Array (in case the variable was unset) ilGen.Emit(OpCodes.Callvirt, PHPCoreConvert.GetMethod("ToArray", new Type[] { PHPMixed })); // if value of offset is null, push null to automatically calculate key if (var.offset.value == null) ilGen.Emit(OpCodes.Ldnull); // if a value is given, push that value else Visit(var.offset.value); Visit(value); if (!(value is REFERENCE)) ilGen.Emit(OpCodes.Call, PHPCoreLang.GetMethod("Clone", new Type[] { PHPMixed })); ilGen.Emit(OpCodes.Callvirt, PHPArray.GetMethod("Append", new Type[] { PHPMixed, PHPMixed })); } } else if (pn.expr is FUNCTION_CALL) { Report.Error(408, pn.line, pn.column); return; } }
public void Add(Expression e) { list.Add(e); }
public LOGICAL_AND(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public MINUS_EQUAL(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public INSTANCEOF(Expression expr, string type, int line, int column) : base(line, column) { this.expr = expr; this.type = type; }
public IS_LOWER_OR_EQUAL(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public CONTINUE(Expression expr, int line, int column) : base(line, column) { this.expr = expr; }
public DO(Statement stmt, Expression expr, int line, int column) : base(line, column) { this.stmt = stmt; this.expr = expr; }
public CLONE(Expression expr, int line, int column) : base(expr, line, column) { }
public CONCAT(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public BREAK(Expression expr, int line, int column) : base(line, column) { this.expr = expr; }
public BOOLEAN_OR(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public BOOLEAN_NOT(Expression expr, int line, int column) : base(expr, line, column) { }
public IF_EXPR(Expression expr1, Expression expr2, Expression expr3, int line, int column) : base(expr1, expr2, expr3, line, column) { }
public ELSEIF(Expression expr, Statement stmt, int line, int column) : base(line, column) { this.expr = expr; this.stmt = stmt; }
public INC(Expression expr, int kind, int line, int column) : base(expr, line, column) { this.kind = kind; }
public EQUALS(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public INT_CAST(Expression expr, int line, int column) : base(expr, line, column) { }
public EXIT(Expression expr, int line, int column) : base(expr, line, column) { }
public IS_NOT_IDENTICAL(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public EXPRESSION_AS_STATEMENT(Expression expr, int line, int column) : base(line, column) { this.expr = expr; }
public LOWER(Expression expr1, Expression expr2, int line, int column) : base(expr1, expr2, line, column) { }
public FOREACH(Expression array, Expression key, Expression value, Statement stmt, int line, int column) : base(line, column) { this.array = array; this.key = key; this.value = value; this.stmt = stmt; }
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.function_name, fc.line, fc.column); if (objectOperatorInProgress) { ilGen.Emit(OpCodes.Pop); objectOperatorInProgress = false; } return; } // process left part objectOperatorInProgress = true; VARIABLE var = (VARIABLE)oo.expr1; // local variable // handle $this-> if (var.name == "$this") { processingObjectThis = 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, PHPCoreRuntime.GetField("thisForStaticContext")); } // otherwise load current object else ilGen.Emit(OpCodes.Ldarg_0); if (var.offset != null) Report.Warn(401, var.offset.line, var.offset.column); } else if (var.name.StartsWith("$")) { processingObjectThis = false; Visit(var); } // class member else { // if processing a class member of $this (of a non-static context), load directly if (processingObjectThis && !fd.modifiers.Contains(Modifiers.STATIC)) LoadFromClassMemberOfThis("$" + var.name, var.line, var.column); // else load at runtime by reflection else LoadFromClassMemberOfAnotherObject("$" + var.name); processingObjectThis = 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, PHPCoreLang.GetMethod("Offset", new Type[] { PHPMixed, PHPMixed, typeof(int) })); } } } // 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); // determine value or reference semantis bool referenceSemantics = false; // if assigned expr is a reference if (value is REFERENCE) { REFERENCE r = (REFERENCE)value; // and a variable is called, it's reference semantics if (r.variable is VARIABLE) referenceSemantics = true; // and a function not returnung a reference is called, it's reference semantics if (r.variable is FUNCTION_CALL) { SymbolTableEntry entry = SymbolTable.getInstance().lookup(((FUNCTION_CALL)r.variable).function_name.ToLower(), SymbolTable.FUNCTION); FUNCTION_DECLARATION fd = (FUNCTION_DECLARATION)entry.node; if (fd.return_by_reference) referenceSemantics = true; } } if (!referenceSemantics) ilGen.Emit(OpCodes.Call, PHPCoreLang.GetMethod("Clone", new Type[] { PHPMixed })); // if processing a class member of $this, store directly if (processingObjectThis) 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 (processingObjectThis) 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.Isinst, PHPNull); ilGen.Emit(OpCodes.Brfalse, skip); ilGen.Emit(OpCodes.Newobj, PHPArray.GetConstructor(Type.EmptyTypes)); // if processing a class member of $this, store directly if (processingObjectThis) 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 (processingObjectThis) 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, PHPCoreConvert.GetMethod("ToArray", new Type[] { PHPMixed })); // if value of offset is null, push null to automatically calculate key if (var2.offset.value == null) ilGen.Emit(OpCodes.Ldnull); // if a value is given, push that value else Visit(var2.offset.value); Visit(value); if (!(value is REFERENCE)) ilGen.Emit(OpCodes.Call, PHPCoreLang.GetMethod("Clone", new Type[] { PHPMixed })); ilGen.Emit(OpCodes.Callvirt, PHPArray.GetMethod("Append", new Type[] { PHPMixed, PHPMixed })); } objectOperatorInProgress = false; } else if (oo.expr2 is FUNCTION_CALL) { FUNCTION_CALL fc = (FUNCTION_CALL)oo.expr2; Report.Warn(403, fc.function_name, fc.line, fc.column); if (objectOperatorInProgress) { ilGen.Emit(OpCodes.Pop); objectOperatorInProgress = false; } return; } }
public ARRAY_PAIR(Expression key, Expression value, int line, int column) : base(line, column) { this.key = key; this.value = value; }
public ExpressionList(Expression e) : this() { list.Add(e); }
public IF(Expression expr, Statement stmt, ArrayList elseif_list, Statement else_stmt, int line, int column) : base(line, column) { this.expr = expr; this.stmt = stmt; this.elseif_list = elseif_list; this.else_stmt = else_stmt; }
public void Remove(Expression expr) { list.Remove(expr); }
public TernaryExpression(Expression expr1, Expression expr2, Expression expr3, int line, int column) : base(line, column) { this.expr1 = expr1; this.expr2 = expr2; this.expr3 = expr3; }