コード例 #1
0
        /// <nodoc />
        public FunctionDeclaration(
            [NotNull] IReadOnlyList <SymbolAtom> @namespace,
            SymbolAtom name,
            [NotNull] CallSignature callSignature,
            [NotNull] Statement body,
            int captures,
            int locals,
            DeclarationFlags modifier,
            LineInfo location,
            StringTable stringTable)
            : base(modifier, location)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(callSignature != null);
            Contract.Requires(body != null);
            Contract.Requires(captures >= 0);
            Contract.Requires(locals >= 0);

            Name          = name;
            CallSignature = callSignature;
            Body          = body;
            Captures      = captures;
            Locals        = locals;

            var fullName = @namespace.ToList();

            fullName.Add(name);
            Statistic = new FunctionStatistic(fullName, callSignature, stringTable);
        }
コード例 #2
0
        /// <summary>
        /// Creates a lambda expression from a call signature and a statement body.
        /// Either 'body' or 'ambient' must additionally be specified.
        /// </summary>
        /// <param name="name">Name of the function if applicable</param>
        /// <param name="callSignature">Signature of the lambda</param>
        /// <param name="body">Body of the lambda; may be null, in which case 'ambient' must be non-null.</param>
        /// <param name="captures">Number of captured variables.</param>
        /// <param name="locals">Number of local variables.  This number *includes* the number of lambda's formal parameters.</param>
        /// <param name="fun">May be given in place of a body statement.  In case 'body' is null, this must be non-null.</param>
        /// <param name="location">Location of the definition.</param>
        /// <param name="statistic">Function invocation statistics</param>
        internal FunctionLikeExpression(
            SymbolAtom name,
            [NotNull] CallSignature callSignature,
            Statement body,
            int captures,
            int locals,
            InvokeAmbient fun,
            LineInfo location,
            FunctionStatistic statistic)
            : base(location)
        {
            Contract.Requires(callSignature != null);
            Contract.Requires(body != null || fun != null);
            Contract.Requires(body == null || fun == null);
            Contract.Requires(captures >= 0);
            Contract.Requires(locals >= 0);
            Contract.Requires(locals >= callSignature.Parameters.Count);

            Name          = name;
            CallSignature = callSignature;
            Body          = body;
            m_ambient     = fun;
            Captures      = captures;
            Locals        = locals;
            Statistic     = statistic;
            Params        = callSignature.Parameters.Count;
        }
コード例 #3
0
        /// <summary>
        ///     Factory method that creates instance of the <see cref="ModuleBinding"/>.
        /// </summary>
        private ModuleBinding CreateFun(string name, InvokeAmbient body, CallSignature signature)
        {
            var atomName  = Symbol(name);
            var statistic = new FunctionStatistic(AmbientName, atomName, signature, StringTable);

            return(ModuleBinding.CreateFun(atomName, body, signature, statistic));
        }
コード例 #4
0
        /// <nodoc />
        public FunctionDeclaration(DeserializationContext context, LineInfo location)
            : base(context, location)
        {
            Name          = ReadSymbolAtom(context);
            CallSignature = Read <CallSignature>(context);
            Body          = Read <Statement>(context);
            Captures      = context.Reader.ReadInt32Compact();
            Locals        = context.Reader.ReadInt32Compact();
            string fullName = context.Reader.ReadString();

            Statistic = new FunctionStatistic(fullName);
        }
コード例 #5
0
 /// <summary>
 /// Creates user-defined function.
 /// </summary>
 public static FunctionLikeExpression CreateFunction(
     SymbolAtom name,
     CallSignature callSignature,
     Statement body,
     int toCapture,
     int locals,
     LineInfo location,
     [NotNull] FunctionStatistic statistic)
 {
     Contract.Requires(name.IsValid);
     return(new FunctionLikeExpression(name, callSignature, body, toCapture, locals, fun: null, location: location, statistic: statistic));
 }
コード例 #6
0
        /// <nodoc />
        protected CallableMember(FunctionStatistic statistic, SymbolAtom name, short minArity, short maxArity, bool rest)
            : base(location: default(LineInfo))
        {
            Contract.Requires(minArity >= 0);
            Contract.Requires(maxArity >= 0);
            Contract.Requires(minArity <= maxArity);

            Name      = name;
            MinArity  = minArity;
            MaxArity  = maxArity;
            Rest      = rest;
            Statistic = statistic;
        }
コード例 #7
0
        /// <nodoc />
        public FunctionLikeExpression(DeserializationContext context, LineInfo location)
            : base(location)
        {
            var reader = context.Reader;

            Name          = reader.ReadSymbolAtom();
            CallSignature = (CallSignature)Read(context);
            Contract.Assert(CallSignature != null);

            Body     = (Statement)Read(context);
            Captures = reader.ReadInt32Compact();
            Locals   = reader.ReadInt32Compact();
            Params   = CallSignature.Parameters.Count;
            var fullName = reader.ReadString();

            Statistic = new FunctionStatistic(fullName);
        }
コード例 #8
0
        private AlgorithmStatistic TestOne(TAlgorithm algorithm, IReadOnlyList <TProblem> problems)
        {
            Assert(problems.Any());

            var functionStatistics = new FunctionStatistic[problems.Count];

            for (var i = 0; i < functionStatistics.Length; i++)
            {
                functionStatistics[i] = TestCase(algorithm, problems[i]);
            }

            Writer.Write($"{algorithm.Name}",
                         FunctionStatistic.Header,
                         functionStatistics);

            return(new AlgorithmStatistic(algorithm.Name, functionStatistics));
        }
コード例 #9
0
        private void InitializeSignaturesAndStatsForProcessOutputs(StringTable stringTable)
        {
            Contract.Requires(stringTable.IsValid());
            m_getOutputFileSignature = CreateSignature(required: RequiredParameters(AmbientTypes.PathType), returnType: AmbientTypes.FileType);
            var name = FunctionStatistic.GetFullNameAsString(
                FunctionStatistic.GetFullName(AmbientName, ExecuteResultGetOutputFile),
                m_getOutputFileSignature,
                stringTable);

            m_getOutputFileStatistic = new FunctionStatistic(AmbientName, ExecuteResultGetOutputFile, m_getOutputFileSignature, stringTable);

            m_getOutputDirectorySignature = CreateSignature(required: RequiredParameters(AmbientTypes.DirectoryType), returnType: AmbientTypes.StaticDirectoryType);
            m_getOutputDirectoryStatistic = new FunctionStatistic(AmbientName, ExecuteResultGetOutputDirectory, m_getOutputDirectorySignature, stringTable);

            m_getOutputFilesSignature = CreateSignature(returnType: AmbientTypes.ArrayType);
            m_getOutputFilesStatistic = new FunctionStatistic(AmbientName, ExecuteResultGetOutputFiles, m_getOutputFilesSignature, stringTable);

            m_getRequiredOutputFilesSignature = CreateSignature(returnType: AmbientTypes.ArrayType);
            m_getRequiredOutputFilesStatistic = new FunctionStatistic(AmbientName, ExecuteResultGetRequiredOutputFiles, m_getRequiredOutputFilesSignature, stringTable);
        }
コード例 #10
0
 /// <nodoc />
 public CallableMember0(FunctionStatistic statistic, SymbolAtom name, CallableMemberSignature0 <T> function, bool isProperty)
     : base(statistic, name, 0, 0, rest: false)
 {
     m_function = function;
     IsProperty = isProperty;
 }
コード例 #11
0
ファイル: CallableMemberN.cs プロジェクト: socat/BuildXL
 /// <nodoc />
 public CallableMemberN(FunctionStatistic statistic, SymbolAtom name, CallableMemberSignatureN <T> function, short minArity, short maxArity, bool rest)
     : base(statistic, name, minArity, maxArity, rest)
 {
     m_function = function;
 }
コード例 #12
0
 /// <summary>
 /// Creates ambient function.
 /// </summary>
 public static FunctionLikeExpression CreateAmbient(SymbolAtom name, CallSignature signature, InvokeAmbient fun, [NotNull] FunctionStatistic statistics)
 {
     Contract.Requires(name.IsValid);
     return(new FunctionLikeExpression(name, signature, fun, default(LineInfo), statistics));
 }
コード例 #13
0
 /// <summary>
 /// Creates a callable expression for the ambient function.
 /// </summary>
 /// <param name="name">Name of the function if applicable</param>
 /// <param name="callSignature">Signature of the lambda.</param>
 /// <param name="ambient">Delegate to serve as lambda's body.</param>
 /// <param name="location">Location of delegates definition.</param>
 /// <param name="statistic">Function invocation statistics.</param>
 private FunctionLikeExpression(SymbolAtom name, [NotNull] CallSignature callSignature, InvokeAmbient ambient, LineInfo location, [NotNull] FunctionStatistic statistic)
     : this(name, callSignature : callSignature, body : null, captures : 0, locals : callSignature.Parameters.Count, fun : ambient, location : location, statistic : statistic)
 {
     Contract.Requires(callSignature != null);
     Contract.Requires(ambient != null);
 }
コード例 #14
0
ファイル: ModuleBinding.cs プロジェクト: kittinap/kunnjae
        /// <summary>
        ///     Creates fun binding.
        /// </summary>
        /// <remarks>
        ///     Used by ambients only!
        /// </remarks>
        public static ModuleBinding CreateFun(SymbolAtom name, InvokeAmbient fun, CallSignature callSignature, FunctionStatistic statistic)
        {
            Contract.Requires(name.IsValid);
            Contract.Requires(fun != null);
            Contract.Requires(callSignature != null);

            return(new ModuleBinding(
                       FunctionLikeExpression.CreateAmbient(name, callSignature, fun, statistic),
                       Declaration.DeclarationFlags.Export, default(LineInfo)));
        }
コード例 #15
0
 /// <nodoc />
 public void Add(FunctionStatistic functionStatistic)
 {
     m_counterNameToCounterIdMap.Enqueue(functionStatistic);
 }