public Expression Resolve(ParseContext ec, ResolveFlags flags) { //if ((flags & ResolveFlags.MaskExprClass) == ResolveFlags.Type) // return ResolveAsTypeStep(ec, false); Expression e; try { if (this is NameExpression) { var intermediate = (flags & ResolveFlags.Intermediate) == ResolveFlags.Intermediate; e = ((NameExpression)this).DoResolve(ec, intermediate); } else { e = DoResolve(ec); } } catch (SyntaxErrorException ex) { ec.Compiler.Errors.Add( ec.Compiler.SourceUnit, ex.Message, Span, ex.ErrorCode, ex.Severity); return(this); } return(e); }
private Expression DoResolve(ParseContext ec, bool leftValue, bool outAccess) { if (!_fieldInfo.IsStatic) { if (InstanceExpression == null) { // // This can happen when referencing an instance field using // a fully qualified type expression: TypeName.InstanceField = xxx // // TODO: SimpleName.Error_ObjectRefRequired(ec, loc, GetSignatureForError()); return(null); } // Resolve the field's instance expression while flow analysis is turned // off: when accessing a field "a.b", we must check whether the field // "a.b" is initialized, not whether the whole struct "a" is initialized. if (leftValue) { var rightSide = outAccess ? EmptyExpression.LValueMemberOutAccess : EmptyExpression.LValueMemberAccess; if (InstanceExpression != EmptyExpression.Null) { InstanceExpression = InstanceExpression.ResolveLValue(ec, rightSide); } } else { const ResolveFlags rf = ResolveFlags.VariableOrValue | ResolveFlags.DisableFlowAnalysis; if (InstanceExpression != EmptyExpression.Null) { InstanceExpression = InstanceExpression.Resolve(ec, rf); } } if (InstanceExpression == null) { return(null); } } // TODO: the code above uses some non-standard multi-resolve rules if (ExpressionClass != ExpressionClass.Invalid) { return(this); } ExpressionClass = ExpressionClass.Variable; // If the instance expression is a local variable or parameter. return(this); }
protected override Expression DoResolve (ResolveContext rc) { var sn = expr as SimpleName; const ResolveFlags flags = ResolveFlags.VariableOrValue | ResolveFlags.Type; if (sn != null) { expr = sn.LookupNameExpression (rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity); // // Resolve expression which does have type set as we need expression type // with disable flow analysis as we don't know whether left side expression // is used as variable or type // if (expr is VariableReference || expr is ConstantExpr || expr is Linq.TransparentMemberAccess) { expr = expr.Resolve (rc); } else if (expr is TypeParameterExpr) { expr.Error_UnexpectedKind (rc, flags, sn.Location); expr = null; } } else { expr = expr.Resolve (rc, flags); } if (expr == null) return null; TypeSpec expr_type = expr.Type; if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod) { expr.Error_OperatorCannotBeApplied (rc, loc, ".", expr_type); return null; } if (targs != null) { if (!targs.Resolve (rc)) return null; } var results = new List<string> (); var nexpr = expr as NamespaceExpression; if (nexpr != null) { string namespaced_partial; if (partial_name == null) namespaced_partial = nexpr.Namespace.Name; else namespaced_partial = nexpr.Namespace.Name + "." + partial_name; rc.CurrentMemberDefinition.GetCompletionStartingWith (namespaced_partial, results); if (partial_name != null) results = results.Select (l => l.Substring (partial_name.Length)).ToList (); } else { var r = MemberCache.GetCompletitionMembers (rc, expr_type, partial_name).Select (l => l.Name); AppendResults (results, partial_name, r); } throw new CompletionResult (partial_name == null ? "" : partial_name, results.Distinct ().ToArray ()); }
/// <summary> /// called to synchronously resolve a hostname. warning this method may /// block the calling thread for a long period of time. it is extremely /// unwise to call this function on the UI thread of an application. /// </summary> /// <param name="hostName"></param> /// <param name="flags"></param> /// <returns></returns> public static DnsRecord Resolve(string hostName, ResolveFlags flags) { if (hostName == null) { throw new ArgumentException("parameter cannot be null", "hostName"); } return(Gecko.Interop.ExtensionMethods.Wrap(nsString.Pass(_dnsService.Instance.Resolve, hostName, (uint)flags), x => new DnsRecord(x))); }
/// <summary> /// called to synchronously resolve a hostname. warning this method may /// block the calling thread for a long period of time. it is extremely /// unwise to call this function on the UI thread of an application. /// </summary> /// <param name="hostName"></param> /// <param name="flags"></param> /// <returns></returns> public static DnsRecord Resolve(string hostName, ResolveFlags flags) { if (hostName == null) { throw new ArgumentException("parameter cannot be null", "hostName"); } nsIDNSRecord record = nsString.Pass(_dnsService.Instance.Resolve, hostName, ( uint )flags); return(DnsRecord.Create(record)); }
/// <summary> /// called to synchronously resolve a hostname. warning this method may /// block the calling thread for a long period of time. it is extremely /// unwise to call this function on the UI thread of an application. /// </summary> /// <param name="hostName"></param> /// <param name="flags"></param> /// <returns></returns> public static DnsRecord Resolve(string hostName, ResolveFlags flags) { if ( hostName == null ) { throw new ArgumentException( "parameter cannot be null", "hostName" ); } return nsString.Pass( _dnsService.Instance.Resolve, hostName, ( uint ) flags ) .Wrap( x => new DnsRecord( x ) ); }
/// <summary> /// called to synchronously resolve a hostname. warning this method may /// block the calling thread for a long period of time. it is extremely /// unwise to call this function on the UI thread of an application. /// </summary> /// <param name="hostName"></param> /// <param name="flags"></param> /// <returns></returns> public static DnsRecord Resolve(string hostName, ResolveFlags flags) { if (hostName == null) { throw new ArgumentException("parameter cannot be null", "hostName"); } //return nsString.Pass(_dnsService.Instance.Resolve, hostName, (uint) flags) // .Wrap(x => new DnsRecord(x)); throw new NotImplementedException(); }
/// <summary> /// called to synchronously resolve a hostname. warning this method may /// block the calling thread for a long period of time. it is extremely /// unwise to call this function on the UI thread of an application. /// </summary> /// <param name="hostName"></param> /// <param name="flags"></param> /// <returns></returns> public static DnsRecord Resolve(string hostName, ResolveFlags flags) { if (hostName==null) { throw new ArgumentException( "parameter cannot be null", "hostName" ); } nsIDNSRecord record = null; using (nsAUTF8String value=new nsAUTF8String(hostName) ) { record = _dnsService.Instance.Resolve(value, (uint)flags); } return record == null ? null : new DnsRecord( record ); }
/// <summary> /// called to synchronously resolve a hostname. warning this method may /// block the calling thread for a long period of time. it is extremely /// unwise to call this function on the UI thread of an application. /// </summary> /// <param name="hostName"></param> /// <param name="flags"></param> /// <returns></returns> public static DnsRecord Resolve(string hostName, ResolveFlags flags) { if (hostName == null) { throw new ArgumentException("parameter cannot be null", "hostName"); } nsIDNSRecord record = null; using (nsAUTF8String value = new nsAUTF8String(hostName)) { record = _dnsService.Instance.Resolve(value, (uint)flags); } return(record == null ? null : new DnsRecord(record)); }
public void OnErrorUnexpectedKind(ParseContext ec, ResolveFlags flags, SourceSpan span) { var valid = new string[4]; int count = 0; if ((flags & ResolveFlags.VariableOrValue) != 0) { valid[count++] = "variable"; valid[count++] = "value"; } if ((flags & ResolveFlags.Type) != 0) { valid[count++] = "type"; } if ((flags & ResolveFlags.MethodGroup) != 0) { valid[count++] = "method group"; } if (count == 0) { valid[count++] = "unknown"; } var sb = new StringBuilder(valid[0]); for (int i = 1; i < count - 1; i++) { sb.Append("', '"); sb.Append(valid[i]); } if (count > 1) { sb.Append("' or '"); sb.Append(valid[count - 1]); } ec.ReportError( CompilerErrors.UnexpectedExpressionKind, span, ExpressionClassName, sb.ToString()); }
/// <summary> /// Attempts to find the target of a Shell link, even if it has been moved or renamed. /// </summary> /// <param name="flags"> Flags that control the resolution process </param> /// <param name="noUxTimeoutMs"> The timeout, in ms, to wait for resolution when there is no UX </param> public void Resolve(ResolveFlags flags, int noUxTimeoutMs) { if ((flags & ResolveFlags.NoUi) == 0) { throw new ArgumentException("This methiod requires that the ResolveFlags.NoUi flag is set in the flags parameter."); } if (noUxTimeoutMs > short.MaxValue) { throw new ArgumentException(string.Format("the nouxTimeoutMs value must be <= {0}", short.MaxValue)); } unchecked { flags = flags & (ResolveFlags)0x0000FFFF; flags |= (ResolveFlags)(noUxTimeoutMs << 16); } shellLink.Resolve(IntPtr.Zero, (SLR_FLAGS)flags); }
public static RenderTexture ResolveVideoToRenderTexture(Material resolveMaterial, RenderTexture targetTexture, ITextureProducer texture, ResolveFlags flags, ScaleMode scaleMode = ScaleMode.StretchToFill) { int targetWidth = texture.GetTexture(0).width; int targetHeight = texture.GetTexture(0).height; GetResolveTextureSize(texture.GetTextureAlphaPacking(), texture.GetTextureStereoPacking(), StereoEye.Left, ref targetWidth, ref targetHeight); if (targetTexture) { bool sizeChanged = (targetTexture.width != targetWidth || targetTexture.height != targetHeight); if (sizeChanged) { RenderTexture.ReleaseTemporary(targetTexture); targetTexture = null; } } if (!targetTexture) { RenderTextureReadWrite readWrite = ((flags & ResolveFlags.ColorspaceSRGB) == ResolveFlags.ColorspaceSRGB) ? RenderTextureReadWrite.sRGB : RenderTextureReadWrite.Linear; targetTexture = RenderTexture.GetTemporary(targetWidth, targetHeight, 0, RenderTextureFormat.ARGB32, readWrite); } // Set target mipmap generation support { bool requiresMipmap = (flags & ResolveFlags.Mipmaps) == ResolveFlags.Mipmaps; bool requiresRecreate = (targetTexture.IsCreated() && targetTexture.useMipMap != requiresMipmap); if (requiresRecreate) { targetTexture.Release(); } if (!targetTexture.IsCreated()) { targetTexture.useMipMap = targetTexture.autoGenerateMips = requiresMipmap; targetTexture.Create(); } } // Render resolve blit // TODO: combine these two paths into a single material blit { bool prevSRGB = GL.sRGBWrite; GL.sRGBWrite = targetTexture.sRGB; RenderTexture prev = RenderTexture.active; if (scaleMode == ScaleMode.StretchToFill) { Graphics.Blit(texture.GetTexture(0), targetTexture, resolveMaterial); } else { RenderTexture.active = targetTexture; bool partialAreaRender = (scaleMode == ScaleMode.ScaleToFit); if (partialAreaRender) { GL.Clear(false, true, Color.black); } VideoRender.DrawTexture(new Rect(0f, 0f, targetTexture.width, targetTexture.height), texture.GetTexture(0), scaleMode, texture.GetTextureAlphaPacking(), resolveMaterial); } RenderTexture.active = prev; GL.sRGBWrite = prevSRGB; } return(targetTexture); }
/// <summary> /// Attempts to find the target of a Shell link, even if it has been moved or renamed. /// </summary> /// <param name="hwnd"> A handle to the window that the Shell will use as the parent for a dialog box. The Shell displays the dialog box if it needs to prompt the user for more information while resolving a Shell link. </param> /// <param name="flags"> Flags that control the resolution process </param> public void Resolve(IntPtr hwnd, ResolveFlags flags) { shellLink.Resolve(hwnd, (SLR_FLAGS)flags); }
/// <summary> /// Attempts to find the target of a Shell link, even if it has been moved or renamed. /// </summary> /// <param name="flags"> Flags that control the resolution process </param> public void Resolve(ResolveFlags flags) { shellLink.Resolve(IntPtr.Zero, (SLR_FLAGS)flags); }
/// <summary> /// Resolves an expression and performs semantic analysis on it. /// </summary> /// /// <remarks> /// Currently Resolve wraps DoResolve to perform sanity /// checking and assertion checking on what we expect from Resolve. /// </remarks> public Expression Resolve(ResolveContext ec, ResolveFlags flags) { if (eclass != ExprClass.Unresolved) return this; Expression e; if (this is SimpleName) { e = ((SimpleName) this).DoResolve (ec, (flags & ResolveFlags.Intermediate) != 0); } else { e = DoResolve (ec); } if (e == null) return null; if ((flags & e.ExprClassToResolveFlags) == 0) { e.Error_UnexpectedKind (ec, flags, loc); return null; } if (e.type == null) throw new InternalErrorException ("Expression `{0}' didn't set its type in DoResolve", e.GetType ()); return e; }
public void Error_UnexpectedKind(ResolveContext ec, ResolveFlags flags, Location loc) { string [] valid = new string [4]; int count = 0; if ((flags & ResolveFlags.VariableOrValue) != 0) { valid [count++] = "variable"; valid [count++] = "value"; } if ((flags & ResolveFlags.Type) != 0) valid [count++] = "type"; if ((flags & ResolveFlags.MethodGroup) != 0) valid [count++] = "method group"; if (count == 0) valid [count++] = "unknown"; StringBuilder sb = new StringBuilder (valid [0]); for (int i = 1; i < count - 1; i++) { sb.Append ("', `"); sb.Append (valid [i]); } if (count > 1) { sb.Append ("' or `"); sb.Append (valid [count - 1]); } ec.Report.Error (119, loc, "Expression denotes a `{0}', where a `{1}' was expected", ExprClassName, sb.ToString ()); }
/// <summary> /// Resolves an expression and performs semantic analysis on it. /// </summary> /// /// <remarks> /// Currently Resolve wraps DoResolve to perform sanity /// checking and assertion checking on what we expect from Resolve. /// </remarks> public Expression Resolve (EmitContext ec, ResolveFlags flags) { if ((flags & ResolveFlags.MaskExprClass) == ResolveFlags.Type) return ResolveAsTypeStep (ec, false); bool do_flow_analysis = ec.DoFlowAnalysis; bool omit_struct_analysis = ec.OmitStructFlowAnalysis; if ((flags & ResolveFlags.DisableFlowAnalysis) != 0) do_flow_analysis = false; if ((flags & ResolveFlags.DisableStructFlowAnalysis) != 0) omit_struct_analysis = true; Expression e; using (ec.WithFlowAnalysis (do_flow_analysis, omit_struct_analysis)) { if (this is SimpleName) { bool intermediate = (flags & ResolveFlags.Intermediate) == ResolveFlags.Intermediate; e = ((SimpleName) this).DoResolve (ec, intermediate); } else { e = DoResolve (ec); } } if (e == null) return null; if ((flags & e.ExprClassToResolveFlags) == 0) { e.Error_UnexpectedKind (flags, loc); return null; } if (e.type == null && !(e is Namespace)) { throw new Exception ( "Expression " + e.GetType () + " did not set its type after Resolve\n" + "called from: " + this.GetType ()); } return e; }
public Expression DoResolve (EmitContext ec, Expression right_side, ResolveFlags flags) { if (type != null) throw new Exception (); // // Resolve the expression with flow analysis turned off, we'll do the definite // assignment checks later. This is because we don't know yet what the expression // will resolve to - it may resolve to a FieldExpr and in this case we must do the // definite assignment check on the actual field and not on the whole struct. // Expression original = expr; expr = expr.Resolve (ec, flags | ResolveFlags.DisableFlowAnalysis); if (expr == null) return null; if (expr is SimpleName){ SimpleName child_expr = (SimpleName) expr; Expression new_expr = new SimpleName (child_expr.Name, Identifier, loc); return new_expr.Resolve (ec, flags); } // // TODO: I mailed Ravi about this, and apparently we can get rid // of this and put it in the right place. // // Handle enums here when they are in transit. // Note that we cannot afford to hit MemberLookup in this case because // it will fail to find any members at all // int errors = Report.Errors; Type expr_type = expr.Type; if ((expr is TypeExpr) && (expr_type == TypeManager.enum_type || expr_type.IsSubclassOf (TypeManager.enum_type))){ Enum en = TypeManager.LookupEnum (expr_type); if (en != null) { object value = en.LookupEnumValue (ec, Identifier, loc); if (value != null){ Constant c = Constantify (value, en.UnderlyingType); return new EnumConstant (c, expr_type); } } } if (expr_type.IsPointer){ Error (23, "The `.' operator can not be applied to pointer operands (" + TypeManager.CSharpName (expr_type) + ")"); return null; } member_lookup = MemberLookupFinal (ec, expr_type, expr_type, Identifier, loc); if (member_lookup == null) return null; if (member_lookup is TypeExpr){ member_lookup.Resolve (ec, ResolveFlags.Type); return member_lookup; } else if ((flags & ResolveFlags.MaskExprClass) == ResolveFlags.Type) return null; member_lookup = ResolveMemberAccess (ec, member_lookup, expr, loc, original); if (member_lookup == null) return null; // The following DoResolve/DoResolveLValue will do the definite assignment // check. if (right_side != null) member_lookup = member_lookup.DoResolveLValue (ec, right_side); else member_lookup = member_lookup.DoResolve (ec); return member_lookup; }
protected override Expression DoResolve(ResolveContext rc) { var sn = expr as SimpleName; const ResolveFlags flags = ResolveFlags.VariableOrValue | ResolveFlags.Type; // // Resolve the expression with flow analysis turned off, we'll do the definite // assignment checks later. This is because we don't know yet what the expression // will resolve to - it may resolve to a FieldExpr and in this case we must do the // definite assignment check on the actual field and not on the whole struct. // using (rc.Set(ResolveContext.Options.OmitStructFlowAnalysis)) { if (sn != null) { expr = sn.LookupNameExpression(rc, MemberLookupRestrictions.ReadAccess | MemberLookupRestrictions.ExactArity); // // Resolve expression which does have type set as we need expression type // with disable flow analysis as we don't know whether left side expression // is used as variable or type // if (expr is VariableReference || expr is ConstantExpr || expr is Linq.TransparentMemberAccess) { using (rc.With(ResolveContext.Options.DoFlowAnalysis, false)) { expr = expr.Resolve(rc); } } else if (expr is TypeParameterExpr) { expr.Error_UnexpectedKind(rc, flags, sn.Location); expr = null; } } else { expr = expr.Resolve(rc, flags); } } if (expr == null) { return(null); } TypeSpec expr_type = expr.Type; if (expr_type.IsPointer || expr_type.Kind == MemberKind.Void || expr_type == InternalType.NullLiteral || expr_type == InternalType.AnonymousMethod) { expr.Error_OperatorCannotBeApplied(rc, loc, ".", expr_type); return(null); } if (targs != null) { if (!targs.Resolve(rc)) { return(null); } } var results = new List <string> (); if (expr is Namespace) { Namespace nexpr = expr as Namespace; string namespaced_partial; if (partial_name == null) { namespaced_partial = nexpr.Name; } else { namespaced_partial = nexpr.Name + "." + partial_name; } rc.CurrentMemberDefinition.GetCompletionStartingWith(namespaced_partial, results); if (partial_name != null) { results = results.Select(l => l.Substring(partial_name.Length)).ToList(); } } else { var r = MemberCache.GetCompletitionMembers(rc, expr_type, partial_name).Select(l => l.Name); AppendResults(results, partial_name, r); } throw new CompletionResult(partial_name == null ? "" : partial_name, results.Distinct().ToArray()); }