/// <summary> /// Helper method /// </summary> /// <param name="items"></param> /// <returns></returns> public static IPhpValue ConcatStrings(params IPhpValue[] items) { if (items == null) { return(null); } IPhpValue result = null; foreach (var i in items) { if (result == null) { result = i; } else { result = new PhpBinaryOperatorExpression(".", result, i); } } if (result != null) { var simplifier = new ExpressionSimplifier(new OptimizeOptions()); result = simplifier.Simplify(result); } return(result); }
/* * /// <summary> * /// Tworzy instancję obiektu * /// </summary> * public PhpForStatement() * { * } * Przykłady użycia * implement INotifyPropertyChanged * implement INotifyPropertyChanged_Passive * implement ToString ##InitVariables## ##Condition## ##Statement## ##Incrementors## * implement ToString InitVariables=##InitVariables##, Condition=##Condition##, Statement=##Statement##, Incrementors=##Incrementors## * implement equals InitVariables, Condition, Statement, Incrementors * implement equals * * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="InitVariables"></param> /// <param name="Condition"></param> /// <param name="Statement"></param> /// <param name="Incrementors"></param> /// </summary> public PhpForStatement(PhpAssignExpression[] InitVariables, IPhpValue Condition, IPhpStatement Statement, IPhpStatement[] Incrementors) { this.InitVariables = InitVariables; this.Condition = Condition; this.Statement = Statement; this.Incrementors = Incrementors; }
/* * /// <summary> * /// Tworzy instancję obiektu * /// </summary> * public PhpForEachStatement() * { * } * Przykłady użycia * implement INotifyPropertyChanged * implement INotifyPropertyChanged_Passive * implement ToString ##KeyVarname## ##ValueVarname## ##OneVariable## ##Collection## ##Statement## * implement ToString KeyVarname=##KeyVarname##, ValueVarname=##ValueVarname##, OneVariable=##OneVariable##, Collection=##Collection##, Statement=##Statement## * implement equals KeyVarname, ValueVarname, OneVariable, Collection, Statement * implement equals * * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="KeyVarname"></param> /// <param name="ValueVarname"></param> /// <param name="Collection"></param> /// <param name="Statement"></param> /// </summary> public PhpForEachStatement(string KeyVarname, string ValueVarname, IPhpValue Collection, IPhpStatement Statement) { this.KeyVarname = KeyVarname; this.ValueVarname = ValueVarname; this.Collection = Collection; this.Statement = Statement; }
void Append(IPhpValue value) { if (value is PhpBinaryOperatorExpression) { var v1 = value as PhpBinaryOperatorExpression; if (v1.Operator == ".") { Append(v1.Left); Append(v1.Right); return; } } if (value is PhpConstValue) { var vv = (PhpConstValue)value; if (vv.Value is string) { Append((string)vv.Value); return; } if (vv.Value is int) { Append(((int)vv.Value).ToString()); return; } } if (value is PhpConditionalExpression || value is PhpBinaryOperatorExpression) { var p = new PhpParenthesizedExpression(value); Append(p); return; } list.Add(value); }
/// <summary> /// Tworzy instancję obiektu /// <param name="fieldName"></param> /// <param name="targetObject"></param> /// <param name="includeModule"></param> /// </summary> public PhpInstanceFieldAccessExpression(string fieldName, IPhpValue targetObject, PhpCodeModuleName includeModule) { FieldName = fieldName; TargetObject = targetObject; IncludeModule = includeModule; }
public IPhpValue MakeSetValueExpression(IPhpValue v) { if (translationInfo == null) { throw new ArgumentNullException("translationInfo"); } if (translationInfo.IsStatic) { throw new NotSupportedException(); } if (translationInfo.GetSetByMethod) { var a = new PhpMethodCallExpression(translationInfo.SetMethodName); a.Arguments.Add(new PhpMethodInvokeValue(v)); a.TargetObject = targetObject; return(a); } else { var a = new PhpInstanceFieldAccessExpression(translationInfo.FieldScriptName, targetObject, null); var b = new PhpAssignExpression(a, v); return(b); } }
// Public Methods public static IPhpValue Strip(IPhpValue x) { if (x is PhpParenthesizedExpression) { return(Strip((x as PhpParenthesizedExpression).expression)); } return(x); }
/// <summary> /// Tworzy instancję obiektu /// <param name="keyVarname"></param> /// <param name="valueVarname"></param> /// <param name="collection"></param> /// <param name="statement"></param> /// </summary> public PhpForEachStatement(string keyVarname, string valueVarname, IPhpValue collection, IPhpStatement statement) { KeyVarname = keyVarname; ValueVarname = valueVarname; Collection = collection; Statement = statement; }
/// <summary> /// Tworzy instancję obiektu /// <param name="initVariables"></param> /// <param name="condition"></param> /// <param name="statement"></param> /// <param name="incrementors"></param> /// </summary> public PhpForStatement(PhpAssignExpression[] initVariables, IPhpValue condition, IPhpStatement statement, IPhpStatement[] incrementors) { InitVariables = initVariables; Condition = condition; Statement = statement; Incrementors = incrementors; }
/// <summary> /// Gets expected return type mask of given symbol (field, function, method or property). /// </summary> /// <remarks>Returned type mask corresponds to types that can be returned by invoking given symbol.</remarks> public static TypeRefMask GetResultType(this IPhpValue symbol, TypeRefContext ctx) { Contract.ThrowIfNull(symbol); Contract.ThrowIfNull(ctx); TypeSymbol t; if (symbol is FieldSymbol) { t = ((FieldSymbol)symbol).Type; } else if (symbol is MethodSymbol) { var m = (MethodSymbol)symbol; var r = symbol as SourceRoutineSymbol; if (r != null && r.IsStatic && r.SyntaxReturnType == null) { // In case of a static function, we can return expected return type mask exactly. // Such function cannot be overriden and we know exactly what the return type will be even the CLR type covers more possibilities. return(ctx.AddToContext(r.TypeRefContext, r.ResultTypeMask)); } t = m.ReturnType; } else if (symbol is PropertySymbol) { t = ((PropertySymbol)symbol).Type; } else if (symbol is ParameterSymbol) { var ps = (ParameterSymbol)symbol; t = ps.Type; if (ps.IsParams) { Debug.Assert(t.IsSZArray()); return(ctx.GetArrayTypeMask(TypeRefFactory.CreateMask(ctx, ((ArrayTypeSymbol)t).ElementType))); } } else { throw Roslyn.Utilities.ExceptionUtilities.UnexpectedValue(symbol); } // create the type mask from the CLR type symbol var mask = TypeRefFactory.CreateMask(ctx, t); // [CastToFalse] if (symbol is IPhpRoutineSymbol && ((IPhpRoutineSymbol)symbol).CastToFalse) { mask |= ctx.GetBooleanTypeMask(); // the function may return FALSE } // return(mask); }
// Private Methods IPhpValue AAA(IPhpValue x) { var constExpression = x as PhpDefinedConstExpression; if (constExpression == null) { return(x); } return(constExpression.DefinedConstName == "PHP_EOL" ? new PhpConstValue("\r\n") : x); }
private static string Collect(PhpSourceCodeEmiter emiter, PhpEmitStyle style, IPhpValue[] collection) { var list = new List<string>(); var xStyle = PhpEmitStyle.xClone(style); xStyle.AsIncrementor = true; foreach (var item in collection) { list.Add(item.GetPhpCode(xStyle)); } return string.Join(", ", list); }
// Private Methods private static IPhpValue _FilterVar(IExternalTranslationContext ctx, CsharpMethodCallExpression src) { var mn = src.MethodInfo.Name; var fn = src.MethodInfo.ToString(); #region ValidateBoolean(System.Object) if (fn == "System.Nullable`1[System.Boolean] ValidateBoolean(System.Object)") { var filter_var = Make_FilterVar( ctx.TranslateValue(src.Arguments[0].MyValue), FILTER_VALIDATE_BOOLEAN, null, FILTER_NULL_ON_FAILURE ); return(filter_var); } #endregion #region ValidateBoolean(System.Object, Boolean) if (fn == "Boolean ValidateBoolean(System.Object, Boolean)") // checked !!!! { return(Make_FilterVar( ctx.TranslateValue(src.Arguments[0].MyValue), FILTER_VALIDATE_BOOLEAN, PhpArrayCreateExpression.MakeKeyValue(new PhpConstValue("default"), ctx.TranslateValue(src.Arguments[1].MyValue)), null )); } #endregion #region ValidateIp if (fn == "System.String ValidateIp(System.Object, Lang.Php.Filters.IpFlags, Lang.Php.Filters.IpOptions)") { IPhpValue flags = null; IPhpValue def = null; if (src.Arguments.Length > 1) { flags = ctx.TranslateValue(src.Arguments[1].MyValue); } if (src.Arguments.Length > 2) { def = ctx.TranslateValue(src.Arguments[2].MyValue); } return(Make_FilterVar( ctx.TranslateValue(src.Arguments[0].MyValue), FILTER_VALIDATE_IP, def, flags)); //PhpArrayCreateExpression.MakeKeyValue( //new PhpConstValue("default"), //ctx.TranslateValue(src.Arguments[1].MyValue)), //ctx.TranslateValue(src.Arguments[1].MyValue) } #endregion throw new NotImplementedException(); }
private static IPhpValue Make_FilterInput(IPhpValue type, IPhpValue name, IPhpValue filter, IPhpValue options, IPhpValue flags = null) { // mixed filter_input ( int $type , string $variable_name [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) var result = new PhpMethodCallExpression("filter_input", type, name, filter, MakeOptionsFlags(options, flags) ); return(result); }
// Protected Methods protected IPhpValue SimplifyForFieldAcces(IPhpValue src, IPhpExpressionSimplifier s) { src = s.Simplify(src); if (!(src is PhpParenthesizedExpression)) return src; var inside = (src as PhpParenthesizedExpression).Expression; if (inside is PhpVariableExpression) return inside; if (inside is PhpMethodCallExpression) return (inside as PhpMethodCallExpression).IsConstructorCall ? src : inside; if (inside is PhpBinaryOperatorExpression || inside is PhpConditionalExpression) return src; throw new NotSupportedException(); }
/// <summary> /// Tworzy instancję obiektu /// <param name="left"></param> /// <param name="right"></param> /// <param name="Operator"></param> /// </summary> public PhpBinaryOperatorExpression(string Operator, IPhpValue left, IPhpValue right) { if (Left == null) { throw new ArgumentNullException(nameof(left)); } if (Right == null) { throw new ArgumentNullException(nameof(right)); } Left = left; Right = right; this.Operator = Operator; }
/* * /// <summary> * /// Tworzy instancję obiektu * /// </summary> * public PhpBinaryOperatorExpression() * { * } * * Przykłady użycia * * implement INotifyPropertyChanged * implement INotifyPropertyChanged_Passive * implement ToString ##Left## ##Right## ##Operator## * implement ToString Left=##Left##, Right=##Right##, Operator=##Operator## * implement equals Left, Right, Operator * implement equals * * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Left"></param> /// <param name="Right"></param> /// <param name="Operator"></param> /// </summary> public PhpBinaryOperatorExpression(string Operator, IPhpValue Left, IPhpValue Right) { left = Left; right = Right; if (left == null) { throw new ArgumentNullException("left"); } if (right == null) { throw new ArgumentNullException("right"); } _operator = Operator; }
// Private Methods private IPhpValue GetDatePart(IPhpValue to, string phpDatePart) { if (to.ToString() == "new DateTime()") { throw new NotImplementedException(); // echo 'Current time: ' . date('Y-m-d H:i:s') . "\n"; // var co = new PhpMethodCallExpression("date", new PhpConstValue(DATE_ONLY)); // var co1 = new PhpMethodCallExpression("date_create_from_format ", new PhpConstValue(DATE_ONLY), co); // return co1; } else { var _for = new PhpMethodCallExpression(to, "format", new PhpConstValue(phpDatePart)); return(MakeInt(_for)); } }
static PhpMethodInvokeValue MakeOptionsFlags(IPhpValue options, IPhpValue flags) { if (flags == null) { return(new PhpMethodInvokeValue(options)); } if (options == null) { return(new PhpMethodInvokeValue(flags)); } var joined = PhpArrayCreateExpression.MakeKeyValue( new PhpConstValue("options"), options, new PhpConstValue("flags"), flags ); return(new PhpMethodInvokeValue(joined)); // new PhpConstValue("flags"), a1); }
public IPhpValue MakeSetValueExpression(IPhpValue v) { if (translationInfo == null) throw new ArgumentNullException("translationInfo"); if (translationInfo.IsStatic) throw new NotSupportedException(); if (translationInfo.GetSetByMethod) { var a = new PhpMethodCallExpression(translationInfo.SetMethodName); a.Arguments.Add(new PhpMethodInvokeValue(v)); a.TargetObject = targetObject; return a; } else { var a = new PhpInstanceFieldAccessExpression(translationInfo.FieldScriptName, targetObject, null); var b = new PhpAssignExpression(a, v); return b; } }
private static IPhpValue Make_FilterVar(IPhpValue value, IPhpValue filter, IPhpValue options, IPhpValue flags = null) { // mixed filter_var ( mixed $variable [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) IPhpValue result; if (options != null || flags != null) { result = new PhpMethodCallExpression("filter_var", value, filter, MakeOptionsFlags(options, flags) ); } else { result = new PhpMethodCallExpression("filter_var", value, filter ); } return(result); }
// Protected Methods protected IPhpValue SimplifyForFieldAcces(IPhpValue src, IPhpExpressionSimplifier s) { src = s.Simplify(src); if (!(src is PhpParenthesizedExpression)) { return(src); } var inside = (src as PhpParenthesizedExpression).Expression; if (inside is PhpVariableExpression) { return(inside); } if (inside is PhpMethodCallExpression) { return((inside as PhpMethodCallExpression).IsConstructorCall ? src : inside); } if (inside is PhpBinaryOperatorExpression || inside is PhpConditionalExpression) { return(src); } throw new NotSupportedException(); }
// Private Methods IPhpValue AAA(IPhpValue x) { var constExpression = x as PhpDefinedConstExpression; if (constExpression == null) return x; return constExpression.DefinedConstName == "PHP_EOL" ? new PhpConstValue("\r\n") : x; }
/// <summary> /// Tworzy instancję obiektu /// <param name="name"></param> /// </summary> public PhpMethodCallExpression(IPhpValue targetObject, string name, params IPhpValue[] args) { _name = name; _arguments.AddRange(args.Select(i => new PhpMethodInvokeValue(i))); _targetObject = targetObject; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpForStatement() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##InitVariables## ##Condition## ##Statement## ##Incrementors## implement ToString InitVariables=##InitVariables##, Condition=##Condition##, Statement=##Statement##, Incrementors=##Incrementors## implement equals InitVariables, Condition, Statement, Incrementors implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="InitVariables"></param> /// <param name="Condition"></param> /// <param name="Statement"></param> /// <param name="Incrementors"></param> /// </summary> public PhpForStatement(PhpAssignExpression[] InitVariables, IPhpValue Condition, IPhpStatement Statement, IPhpStatement[] Incrementors) { this.InitVariables = InitVariables; this.Condition = Condition; this.Statement = Statement; this.Incrementors = Incrementors; }
// Public Methods public static IPhpValue Strip(IPhpValue x) { if (x is PhpParenthesizedExpression) return Strip((x as PhpParenthesizedExpression).expression); return x; }
/// <summary> /// Tworzy instancję obiektu /// <param name="operand">,</param> /// <param name="increment"></param> /// <param name="pre"></param> /// </summary> public PhpIncrementDecrementExpression(IPhpValue operand, bool increment, bool pre) { Operand = operand; Increment = increment; Pre = pre; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpInstanceFieldAccessExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##FieldName## ##TargetObject## ##IncludeModule## implement ToString FieldName=##FieldName##, TargetObject=##TargetObject##, IncludeModule=##IncludeModule## implement equals FieldName, TargetObject, IncludeModule implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="FieldName"></param> /// <param name="TargetObject"></param> /// <param name="IncludeModule"></param> /// </summary> public PhpInstanceFieldAccessExpression(string FieldName, IPhpValue TargetObject, PhpCodeModuleName IncludeModule) { fieldName = FieldName; targetObject = TargetObject; this.IncludeModule = IncludeModule; }
private EchoEmitItem[] GetEchoItems(PhpEmitStyle style) { var values = new List <IPhpValue>(); #region Przygotowanie listy elementów do wyświetlenia { var methodCall = _expression as PhpMethodCallExpression; if (methodCall == null) { return (null); } if (methodCall.CallType != MethodCallStyles.Procedural || methodCall.Name != "echo") { return(null); } foreach (var xx in methodCall.Arguments) { values.AddRange(ExpressionSimplifier.ExplodeConcats(xx, ".")); } values = values.Select(AAA).ToList(); #region Łączenie const string for (var i = 1; i < values.Count; i++) { var a1 = values[i - 1]; var a2 = values[i]; if (!(a1 is PhpConstValue) || !(a2 is PhpConstValue)) { continue; } var b1 = (a1 as PhpConstValue).Value; var b2 = (a2 as PhpConstValue).Value; var c1 = PhpValues.ToPhpCodeValue(b1); var c2 = PhpValues.ToPhpCodeValue(b2); if (c1.Kind != PhpCodeValue.Kinds.StringConstant || c1.Kind != PhpCodeValue.Kinds.StringConstant) { continue; } values[i - 1] = new PhpConstValue((string)c1.SourceValue + (string)c2.SourceValue); values.RemoveAt(i); i--; } #endregion } #endregion { IPhpValue echoArguments = null; Action <IPhpValue> vv = u => { // ReSharper disable once AccessToModifiedClosure echoArguments = echoArguments == null ? u : new PhpBinaryOperatorExpression(".", echoArguments, u); }; var result = new List <EchoEmitItem>(); foreach (var value in values) { if (value is PhpConstValue) { var constValue = (value as PhpConstValue).Value; var constStringValue = constValue as string; if (constStringValue != null) { #region Const-string var lines = SplitToLines(constStringValue); foreach (var i in lines) { if (i.EndsWith("\r\n")) { vv(new PhpConstValue(i.Substring(0, i.Length - 2))); vv(new PhpDefinedConstExpression("PHP_EOL", null)); // ReSharper disable once PossibleNullReferenceException result.Add(new EchoEmitItem(echoArguments.GetPhpCode(style), false)); echoArguments = null; } else { vv(new PhpConstValue(i)); } } continue; #endregion } } vv(value); } if (echoArguments != null) { result.Add(new EchoEmitItem(echoArguments.GetPhpCode(style), false)); } return(result.ToArray()); } }
IPhpValue MakeInt(IPhpValue x) { return(new PhpMethodCallExpression("intval", x)); }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpAssignExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Left## ##Right## ##OptionalOperator## implement ToString Left=##Left##, Right=##Right##, OptionalOperator=##OptionalOperator## implement equals Left, Right, OptionalOperator implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Left"></param> /// <param name="Right"></param> /// <param name="OptionalOperator"></param> /// </summary> public PhpAssignExpression(IPhpValue Left, IPhpValue Right, string OptionalOperator) { this.Left = Left; this.Right = Right; this.OptionalOperator = OptionalOperator; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpMethodInvokeValue() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Expression## ##ByRef## implement ToString Expression=##Expression##, ByRef=##ByRef## implement equals Expression, ByRef implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Expression"></param> /// </summary> public PhpMethodInvokeValue(IPhpValue Expression) { this.Expression = Expression; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpIfStatement() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Condition## ##IfTrue## ##IfFalse## implement ToString Condition=##Condition##, IfTrue=##IfTrue##, IfFalse=##IfFalse## implement equals Condition, IfTrue, IfFalse implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="condition"></param> /// <param name="ifTrue"></param> /// <param name="ifFalse"></param> /// </summary> public PhpIfStatement(IPhpValue condition, IPhpStatement ifTrue, IPhpStatement ifFalse) { Condition = condition; IfTrue = ifTrue; IfFalse = ifFalse; }
/* * /// <summary> * /// Tworzy instancję obiektu * /// </summary> * public PhpParenthesizedExpression() * { * } * Przykłady użycia * implement INotifyPropertyChanged * implement INotifyPropertyChanged_Passive * implement ToString ##Expression## * implement ToString Expression=##Expression## * implement equals Expression * implement equals * * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Expression"></param> /// </summary> public PhpParenthesizedExpression(IPhpValue Expression) { expression = Expression; }
/// <summary> /// Tworzy instancję obiektu /// <param name="condition"></param> /// <param name="ifTrue"></param> /// <param name="ifFalse"></param> /// </summary> public PhpIfStatement(IPhpValue condition, IPhpStatement ifTrue, IPhpStatement ifFalse) { Condition = condition; IfTrue = ifTrue; IfFalse = ifFalse; }
/// <summary> /// Tworzy instancję obiektu /// <param name="operand"></param> /// <param name="_operator"></param> /// </summary> public PhpUnaryOperatorExpression(IPhpValue operand, string _operator) { Operand = operand; Operator = _operator; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpExpressionStatement() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Expression## implement ToString Expression=##Expression## implement equals Expression implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="expression"></param> /// </summary> public PhpExpressionStatement(IPhpValue expression) { Expression = expression; }
/// <summary> /// Tworzy instancję obiektu /// <param name="Value"></param> /// </summary> public PhpSwitchLabel(IPhpValue Value) { this.Value = Value; }
/* * /// <summary> * /// Tworzy instancję obiektu * /// </summary> * public PhpExpressionStatement() * { * } * Przykłady użycia * implement INotifyPropertyChanged * implement INotifyPropertyChanged_Passive * implement ToString ##Expression## * implement ToString Expression=##Expression## * implement equals Expression * implement equals * * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="expression"></param> /// </summary> public PhpExpressionStatement(IPhpValue expression) { Expression = expression; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpParenthesizedExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Expression## implement ToString Expression=##Expression## implement equals Expression implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Expression"></param> /// </summary> public PhpParenthesizedExpression(IPhpValue Expression) { expression = Expression; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpPropertyAccessExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##TranslationInfo## ##TargetObject## implement ToString TranslationInfo=##TranslationInfo##, TargetObject=##TargetObject## implement equals TranslationInfo, TargetObject implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="TranslationInfo"></param> /// <param name="TargetObject"></param> /// </summary> public PhpPropertyAccessExpression(PropertyTranslationInfo TranslationInfo, IPhpValue TargetObject) { this.TranslationInfo = TranslationInfo; this.TargetObject = TargetObject; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpConditionalExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Condition## ##WhenTrue## ##WhenFalse## implement ToString Condition=##Condition##, WhenTrue=##WhenTrue##, WhenFalse=##WhenFalse## implement equals Condition, WhenTrue, WhenFalse implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="condition"></param> /// <param name="whenTrue"></param> /// <param name="whenFalse"></param> /// </summary> public PhpConditionalExpression(IPhpValue condition, IPhpValue whenTrue, IPhpValue whenFalse) { Condition = condition; WhenTrue = whenTrue; WhenFalse = whenFalse; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpWhileStatement() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Condition## ##Statement## implement ToString Condition=##Condition##, Statement=##Statement## implement equals Condition, Statement implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="condition"></param> /// <param name="statement"></param> /// </summary> public PhpWhileStatement(IPhpValue condition, IPhpStatement statement) { Condition = condition; Statement = statement; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpElementAccessExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Expression## ##Arguments## implement ToString Expression=##Expression##, Arguments=##Arguments## implement equals Expression, Arguments implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Expression"></param> /// <param name="Arguments"></param> /// </summary> public PhpElementAccessExpression(IPhpValue Expression, IPhpValue[] Arguments) { expression = Expression; arguments = Arguments; }
/// <summary> /// Gets expected return type mask of given symbol (field, function, method or property). /// </summary> /// <remarks>Returned type mask corresponds to types that can be returned by invoking given symbol.</remarks> public static TypeRefMask GetResultType(this IPhpValue symbol, TypeRefContext ctx) { Contract.ThrowIfNull(symbol); Contract.ThrowIfNull(ctx); TypeSymbol t; if (symbol is FieldSymbol) { t = ((FieldSymbol)symbol).Type; } else if (symbol is MethodSymbol) { var m = (MethodSymbol)symbol; var r = symbol as SourceRoutineSymbol; // if the method is generator use ConstructClrReturnType analysis for return type // TODO: would not be necessary if GN_SGS got fixed (the routine could report the return type correctly itself) if (r != null && r.IsGeneratorMethod()) { t = m.ReturnType; } else if (r != null && r.IsStatic && r.SyntaxReturnType == null) { // In case of a static function, we can return expected return type mask exactly. // Such function cannot be overriden and we know exactly what the return type will be even the CLR type covers more possibilities. return(ctx.AddToContext(r.TypeRefContext, r.ResultTypeMask)); } else { t = m.ReturnType; } } else if (symbol is PropertySymbol) { t = ((PropertySymbol)symbol).Type; } else if (symbol is ParameterSymbol) { var ps = (ParameterSymbol)symbol; t = ps.Type; if (ps.IsParams) { Debug.Assert(t.IsSZArray()); return(ctx.GetArrayTypeMask(TypeRefFactory.CreateMask(ctx, ((ArrayTypeSymbol)t).ElementType))); } } else { throw Roslyn.Utilities.ExceptionUtilities.UnexpectedValue(symbol); } // create the type mask from the CLR type symbol var mask = TypeRefFactory.CreateMask(ctx, t); // [CastToFalse] if (symbol is IPhpRoutineSymbol && ((IPhpRoutineSymbol)symbol).CastToFalse) { mask |= ctx.GetBooleanTypeMask(); // the function may return FALSE // remove NULL (NULL is changed to FALSE), note it also can't return -1 mask = ctx.WithoutNull(mask); } // return(mask); }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpIncrementDecrementExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Operand## ##Increment## ##Pre## implement ToString Operand=##Operand##, Increment=##Increment##, Pre=##Pre## implement equals Operand, Increment, Pre implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Operand">,</param> /// <param name="Increment"></param> /// <param name="Pre"></param> /// </summary> public PhpIncrementDecrementExpression(IPhpValue Operand, bool Increment, bool Pre) { this.Operand = Operand; this.Increment = Increment; this.Pre = Pre; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpReturnStatement() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##ReturnValue## implement ToString ReturnValue=##ReturnValue## implement equals ReturnValue implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="returnValue"></param> /// </summary> public PhpReturnStatement(IPhpValue returnValue) { _returnValue = returnValue; }
/// <summary> /// Tworzy instancję obiektu /// <param name="Left"></param> /// <param name="Right"></param> /// </summary> public PhpAssignExpression(IPhpValue Left, IPhpValue Right) { this.Left = Left; this.Right = Right; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpUnaryOperatorExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Operand## ##Operator## implement ToString Operand=##Operand##, Operator=##Operator## implement equals Operand, Operator implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="operand"></param> /// <param name="_operator"></param> /// </summary> public PhpUnaryOperatorExpression(IPhpValue operand, string _operator) { _operand = operand; this._operator = _operator; }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpArrayAccessExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##PhpArray## ##Index## implement ToString PhpArray=##PhpArray##, Index=##Index## implement equals PhpArray, Index implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="phpArray"></param> /// <param name="index"></param> /// </summary> public PhpArrayAccessExpression(IPhpValue phpArray, IPhpValue index) { _phpArray = phpArray; _index = index; }
protected IPhpValue StripBracketsAndSimplify(IPhpValue value, IPhpExpressionSimplifier s) { value = PhpParenthesizedExpression.Strip(value); value = s.Simplify(value); return value; }
/* * /// <summary> * /// Tworzy instancję obiektu * /// </summary> * public PhpPropertyAccessExpression() * { * } * Przykłady użycia * implement INotifyPropertyChanged * implement INotifyPropertyChanged_Passive * implement ToString ##TranslationInfo## ##TargetObject## * implement ToString TranslationInfo=##TranslationInfo##, TargetObject=##TargetObject## * implement equals TranslationInfo, TargetObject * implement equals * * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="TranslationInfo"></param> /// <param name="TargetObject"></param> /// </summary> public PhpPropertyAccessExpression(PropertyTranslationInfo TranslationInfo, IPhpValue TargetObject) { this.TranslationInfo = TranslationInfo; this.TargetObject = TargetObject; }
protected IPhpValue StripBracketsAndSimplify(IPhpValue value, IPhpExpressionSimplifier s) { value = PhpParenthesizedExpression.Strip(value); value = s.Simplify(value); return(value); }
/* /// <summary> /// Tworzy instancję obiektu /// </summary> public PhpBinaryOperatorExpression() { } Przykłady użycia implement INotifyPropertyChanged implement INotifyPropertyChanged_Passive implement ToString ##Left## ##Right## ##Operator## implement ToString Left=##Left##, Right=##Right##, Operator=##Operator## implement equals Left, Right, Operator implement equals * implement equals *, ~exclude1, ~exclude2 */ #region Constructors /// <summary> /// Tworzy instancję obiektu /// <param name="Left"></param> /// <param name="Right"></param> /// <param name="Operator"></param> /// </summary> public PhpBinaryOperatorExpression(string Operator, IPhpValue Left, IPhpValue Right) { left = Left; right = Right; if (left == null) throw new ArgumentNullException("left"); if (right == null) throw new ArgumentNullException("right"); _operator = Operator; }
public IPhpValue Simplify(IPhpValue x) { var a = new ExpressionSimplifier(op); return(a.Visit(x as PhpSourceBase)); }
/// <summary> /// Tworzy instancję obiektu /// <param name="ValueVarname"></param> /// <param name="Collection"></param> /// <param name="Statement"></param> /// </summary> public PhpForEachStatement(string ValueVarname, IPhpValue Collection, IPhpStatement Statement) { this.ValueVarname = ValueVarname; this.Collection = Collection; this.Statement = Statement; }