Esempio n. 1
0
	    public void AddResult (Result r, Fingerprint fp, int index_into_values) 
	    {
		if (index_into_values == -1) {
		    Values.Add (r);
		    FPs.Add (fp);
		} else {
		    Values[index_into_values] = r;
		    FPs[index_into_values] = fp;
		}
	    }
Esempio n. 2
0
	public void AddDependentFile (string fname, Fingerprint fp)
	{
	    if (dep_files.ContainsKey (fname))
		return;

	    DependentItemInfo dii = new DependentItemInfo ();
	    dii.Name = fname;
	    dii.Fingerprint = fp;

	    dep_files[fname] = dii;
	}
Esempio n. 3
0
		public static Fingerprint GetFingerprint (object o, IBuildContext ctxt, Fingerprint cached) {
			if (o == null)
				return Null;

			if (o is IFingerprintable)
				return (o as IFingerprintable).GetFingerprint (ctxt, cached);

			if (o is Boolean)
				return Constant (BitConverter.GetBytes ((bool) o));

			if (o is Byte)
				return Constant (BitConverter.GetBytes ((byte) o));

			if (o is Char)
				return Constant (BitConverter.GetBytes ((char) o));

			if (o is Int16)
				return Constant (BitConverter.GetBytes ((short) o));

			if (o is Int32)
				return Constant (BitConverter.GetBytes ((int) o));

			if (o is Int64)
				return Constant (BitConverter.GetBytes ((long) o));

			if (o is UInt16)
				return Constant (BitConverter.GetBytes ((ushort) o));

			if (o is UInt32)
				return Constant (BitConverter.GetBytes ((uint) o));

			if (o is UInt64)
				return Constant (BitConverter.GetBytes ((ulong) o));

			if (o is Single)
				return Constant (BitConverter.GetBytes ((float) o));

			if (o is Double)
				return Constant (BitConverter.GetBytes ((double) o));

			if (o is String)
				return Fingerprint.FromText ((string) o);

			throw new Exception (String.Format ("Don't know how to get a fingerprint from object of type {0}",
							    o.GetType()));
		}
Esempio n. 4
0
		// Keep this as a separate function so inheritors can call it in their ctors

		protected void Calculate (ICollection coll, IBuildContext ctxt, Fingerprint cached) {
			CompositeFingerprint cf = cached as CompositeFingerprint;

			children = new Fingerprint[coll.Count];
			int i = 0;

			if (cf != null && cf.children.Length == coll.Count) {
				foreach (IFingerprintable item in coll) {
					children[i] = GenericFingerprints.GetFingerprint (item, ctxt, 
											  cf.children[i]);
					i++;
				}
			} else {
				foreach (IFingerprintable item in coll) {
					children[i] = GenericFingerprints.GetFingerprint (item, ctxt, null);
					i++;
				}
			}

			value = Calculate (children);
		}
Esempio n. 5
0
	public override Fingerprint GetFingerprint (IBuildContext ctxt, Fingerprint cached) 
	{
	    return GenericFingerprints.Null;
	}
Esempio n. 6
0
	public bool AddDefaultOrdered (Result r, Fingerprint fp, IWarningLogger logger) 
	{
	    if (r == null)
		throw new ArgumentNullException ();
	    
	    if (default_ordered_id < 0) {
		logger.Error (2037, "Trying to add a dependency to the default " + 
			      "ordered argument, but no default ordered argument is defined",
			      r.ToString ());
		return true;
	    }
	    
	    return AddNamed (default_ordered_id, r, fp, -1, logger);
	}
Esempio n. 7
0
	public bool Add (int aid, Result r, Fingerprint fp, IWarningLogger logger) 
	{
	    if (r == null)
		throw new ArgumentNullException ();
	    
	    return AddNamed (aid, r, fp, -1, logger);
	}
Esempio n. 8
0
	public bool Add (Result r, Fingerprint fp, IWarningLogger logger) 
	{
	    if (r == null)
		throw new ArgumentNullException ();
	    
	    Type t = r.GetType ();
	    List<int> possible_args = new List<int> ();
	    Type best_match = typeof (Result);
	    
	    for (int i = 0; i < args.Length; i++) {
		Type atype = args[i].Type;
		
		// Cannot add an unnamed arg to an ordered arg
		if ((args[i].Flags & ArgFlags.Ordered) != 0)
		    continue;
		
		// Prune out the egregiously wrong arguments (not even a superclass of the result)
		if (! TypeIs (t, atype))
		    continue;
		
		// Prune out those that have been bettered
		if (! TypeIs (atype, best_match))
		    continue;
		
		// If we've narrowed the type further, we don't want any of the
		// previous vaguer matches.
		if (atype.IsSubclassOf (best_match)) {
		    possible_args.Clear ();
		    best_match = atype;
		}
		     
		possible_args.Add (i);
	    }
	    
	    //Console.WriteLine ("Finished with {0} possible arguments", possible_args.Count);
	    
	    if (possible_args.Count == 1) {
		args[possible_args[0]].AddResult (r, fp, -1);
		return false;
	    }
	    
	    if (possible_args.Count > 0) {
		
		// Several possible choices. Check for a default
		foreach (int aid in possible_args) {
		    if ((args[aid].Flags & ArgFlags.Default) != 0) {
			args[aid].AddResult (r, fp, -1);
			return false;
		    }
		}
		
		// No dice. Ambiguity not tolerated. Ah, computers.
		
		StringBuilder sb = new StringBuilder ();
		sb.AppendFormat ("Ambiguous dependency of type {0} could " +
				 "be one of these arguments:", t);
		foreach (int aid in possible_args)
		    sb.AppendFormat (" {0}", args[aid].Name);
		
		logger.Error (2035, sb.ToString (), r.ToString ());
		return true;
	    }

	    // Maybe this is a composite result, and it has a default?
	    // We recurse here, so we tunnel through the composites
	    // sequentially. It's correct to check at every step, rather
	    // than calling FindCompatible, since we don't know what 
	    // type we're looking for.
	    
	    if (r is CompositeResult) {
		CompositeResult cr = (CompositeResult) r;
		
		if (cr.HasDefault) {
		    // See note above about losing FP info in composite results.
		    // this case happens when we are guessing the arg; te 
		    //logger.Warning (9999, "LOSING FINGERPRINT INFO in AC (2)", r.ToString ());
		    
		    if (Add (cr.Default, null, logger) == false)
			return false;
		    
		    // if that didn't work, continue
		    // and give a warning about the container
		    // Result, not the default.
		}
	    }
	    
	    // Bummer.
	    
	    string s = String.Format ("Dependency {0} of type {1} isn't compatible " +
				      "with any defined arguments.", r, t);
	    logger.Error (2034, s, null);
	    return true;
	}
Esempio n. 9
0
	bool AddNamed (int aid, Result r, Fingerprint fp, 
		       int index_into_values, IWarningLogger logger) 
	{
	    if (aid < 0 || aid >= args.Length) {
		string s = String.Format ("Trying to add {0} to nonexistant " +
					  "argument ID {1}.", r, aid);
		logger.Error (2042, s, r.ToString ());
		return true;
	    }

	    Result subres = CompositeResult.FindCompatible (r, args[aid].Type);

	    if (subres == null) {
		string err = String.Format ("Argument value should be of type {0}, but " +
					    "its type is {1}", args[aid].Type, r.GetType ());
		logger.Error (2036, err, r.ToString ());
		return true;
	    }

	    if (subres == r)
		args[aid].AddResult (r, fp, index_into_values);
	    else
		// FIXME: the FP is really invalid, right?
		args[aid].AddResult (r, null, index_into_values);

	    return false;
	}
Esempio n. 10
0
        public static Fingerprint GetFingerprint(object o, IBuildContext ctxt, Fingerprint cached)
        {
            if (o == null)
            {
                return(Null);
            }

            if (o is IFingerprintable)
            {
                return((o as IFingerprintable).GetFingerprint(ctxt, cached));
            }

            if (o is Boolean)
            {
                return(Constant(BitConverter.GetBytes((bool)o)));
            }

            if (o is Byte)
            {
                return(Constant(BitConverter.GetBytes((byte)o)));
            }

            if (o is Char)
            {
                return(Constant(BitConverter.GetBytes((char)o)));
            }

            if (o is Int16)
            {
                return(Constant(BitConverter.GetBytes((short)o)));
            }

            if (o is Int32)
            {
                return(Constant(BitConverter.GetBytes((int)o)));
            }

            if (o is Int64)
            {
                return(Constant(BitConverter.GetBytes((long)o)));
            }

            if (o is UInt16)
            {
                return(Constant(BitConverter.GetBytes((ushort)o)));
            }

            if (o is UInt32)
            {
                return(Constant(BitConverter.GetBytes((uint)o)));
            }

            if (o is UInt64)
            {
                return(Constant(BitConverter.GetBytes((ulong)o)));
            }

            if (o is Single)
            {
                return(Constant(BitConverter.GetBytes((float)o)));
            }

            if (o is Double)
            {
                return(Constant(BitConverter.GetBytes((double)o)));
            }

            if (o is String)
            {
                return(Fingerprint.FromText((string)o));
            }

            throw new Exception(String.Format("Don't know how to get a fingerprint from object of type {0}",
                                              o.GetType()));
        }
Esempio n. 11
0
		// Result

		public override Fingerprint GetFingerprint (IBuildContext ctxt, Fingerprint cached) {
			return this;
		}
Esempio n. 12
0
	    public void FixValue (string basename, Result r, Fingerprint fp) {
		if (fp == null)
		    fp = r.GetFingerprint (context, null);
		
		BuiltItem bi = new BuiltItem (r, fp, GenericFingerprints.Null);
		pp.SetItem (basename, bi);
	    }
Esempio n. 13
0
		public BuiltItem (Result r, Fingerprint rp, Fingerprint bp) {
			Result = r;
			ResultPrint = rp;
			BuildPrint = bp;
		}
Esempio n. 14
0
		// Fingerprinting -- an MD5 of the result's data.
		// Cached is a cached value of the fingerprint; the
		// result implementation may compare some saved hints
		// and return the cached value if deemed appropriate.
		// 
		// It is acceptable if ctxt or cached is null. If cached
		// is null, the cache comparison should be skipped.
		//
		// If the result class needs a context to evaluate the fingerprint,
		// and ctxt is null, and the fingerprint is not cached,
		// throw an exception.

		public abstract Fingerprint GetFingerprint (IBuildContext ctxt, Fingerprint cached);
Esempio n. 15
0
        // Fingerprinting

        public override Fingerprint GetFingerprint(IBuildContext ctxt, Fingerprint cached)
        {
            return(new CompositeFingerprint(store.Values, ctxt, cached));
        }
Esempio n. 16
0
        // Fingerprint

        public override Fingerprint GetFingerprint(IBuildContext ctxt, Fingerprint cached)
        {
            return(Fingerprint.FromText(value));
        }
Esempio n. 17
0
        // Fingerprinting

        public override Fingerprint GetFingerprint(IBuildContext ctxt, Fingerprint cached)
        {
            return(new CompositeFingerprint(GetItems(), ctxt, cached));
        }
Esempio n. 18
0
		public CompositeFingerprint (ICollection coll, IBuildContext ctxt, Fingerprint cached) : base () {
			Calculate (coll, ctxt, cached);
		}
Esempio n. 19
0
	bool CheckBuildReadiness () 
	{
	    if (Rule == null || Args == null)
		// Error will have been reported
		return true;

	    if (!Args.ArgsFinalized) {
		if (Args.FinalizeArgs (proj.BuildManager, proj.Log))
		    return true;
	    }

	    if (cur_build_fp == null)
		cur_build_fp = MakeBuildPrint (Rule, Args, pi.context);

	    // Do this after setting cur_build_fp in case the
	    // rule somehow is incorrently including arg state
	    // in its fingerprint.

	    Rule.FetchArgValues (Args);

	    return false;
	}
Esempio n. 20
0
		// Fingerprinting

		public override Fingerprint GetFingerprint (IBuildContext ctxt, Fingerprint cached) {
			return new CompositeFingerprint (store.Values, ctxt, cached);
		}
Esempio n. 21
0
		// Fingerprinting

		public override Fingerprint GetFingerprint (IBuildContext ctxt, Fingerprint cached) {
			return new CompositeFingerprint (GetItems (), ctxt, cached);
		}
Esempio n. 22
0
		// fingerprint

		public override Fingerprint GetFingerprint (IBuildContext ctxt, Fingerprint cached) {
			DateTime ondisk = GetModTime (ctxt);
			Fingerprint result;

			if (cached != null && modtime == ondisk) {
				//string path = GetPath (ctxt);
				//ctxt.Logger.Log ("io.file_fingerCACHE", "XXXXXXXX " + path);
				result = cached;
			} else {
				// Don't use OpenRead: the buffered stream would be useless
				string path = GetPath (ctxt);
				//string s = cached == null ? "nocached " : "modtime  ";
				//ctxt.Logger.Log ("io.file_fingerprint", s + path);
				ctxt.Logger.Log ("io.file_fingerprint", path);
				result = Fingerprint.FromFile (path);
				modtime = ondisk;
			}

			return result;
		}
Esempio n. 23
0
        // Fingerprinting -- an MD5 of the result's data.
        // Cached is a cached value of the fingerprint; the
        // result implementation may compare some saved hints
        // and return the cached value if deemed appropriate.
        //
        // It is acceptable if ctxt or cached is null. If cached
        // is null, the cache comparison should be skipped.
        //
        // If the result class needs a context to evaluate the fingerprint,
        // and ctxt is null, and the fingerprint is not cached,
        // throw an exception.

        public abstract Fingerprint GetFingerprint(IBuildContext ctxt, Fingerprint cached);