Exemple #1
0
        public object visitNotSentence(NotSentence sentence, object arg)
        {
            ArgData ad = (ArgData)arg;

            // Indicate that the enclosed predicate is negated
            ad.negated = true;
            sentence.getNegated().accept(this, arg);
            ad.negated = false;

            return(sentence);
        }
        /// <summary>
        /// Helper method that does the actual job -- calls <see cref="_Get"/> recursively
        /// as needed.
        /// </summary>
        static private void _Get(ArgData data, int sheetIndex)
        {
            if (sheetIndex > data.numSheets) // sheet indices are 1-based
            {
                return;                      // past last sheet
            }
            object tool = GetTool(data, sheetIndex);

            if (tool == null)
            {
                // This property sheet has no settings for this tool,
                // but perhaps the next one has.
                _Get(data, sheetIndex + 1);
                return;
            }

            List <string> list = data.propGetter(tool);

            if (list == null)
            {
                // This property sheet isn't customizing this particular setting,
                // but perhaps the next one does.
                _Get(data, sheetIndex + 1);
                return;
            }

            // If $(NoInherit) appears anywhere within the property, inheritance stops
            // right here, and even implicit $(Inherit) will be ignored.
            bool noInherit = list.Contains("$(NoInherit)");

            // Look for $(Inherit) elements and run recursively
            bool explicitInherit = false;

            foreach (string item in list)
            {
                if (!noInherit && item == "$(Inherit)")
                {
                    explicitInherit = true;
                    _Get(data, sheetIndex + 1); // inherit from next sheet
                }
                else
                {
                    data.result.Add(item);
                }
            }

            // If there was no explicit $(Inherit) anywhere in the property,
            // we "append" an implicit one at the end.
            if (!noInherit && !explicitInherit)
            {
                _Get(data, sheetIndex + 1); // inherit from next sheet
            }
        }
Exemple #3
0
        public object VisitTermEquality(TermEquality equality, object arg)
        {
            ArgData ad = (ArgData)arg;

            if (ad.Negated)
            {
                ad.Clauses[ad.Clauses.Count - 1].AddNegativeLiteral(equality);
            }
            else
            {
                ad.Clauses[ad.Clauses.Count - 1].AddPositiveLiteral(equality);
            }
            return(equality);
        }
Exemple #4
0
        public Object visitTermEquality(TermEquality equality, Object arg)
        {
            ArgData ad = (ArgData)arg;

            if (ad.negated)
            {
                ad.clauses[ad.clauses.Count - 1].addNegativeLiteral(equality);
            }
            else
            {
                ad.clauses[ad.clauses.Count - 1].addPositiveLiteral(equality);
            }
            return(equality);
        }
Exemple #5
0
        public Object visitPredicate(Predicate p, Object arg)
        {
            ArgData ad = (ArgData)arg;

            if (ad.negated)
            {
                ad.clauses[ad.clauses.Count - 1].addNegativeLiteral(p);
            }
            else
            {
                ad.clauses[ad.clauses.Count - 1].addPositiveLiteral(p);
            }
            return(p);
        }
Exemple #6
0
        public object visitTermEquality(TermEquality equality, object arg)
        {
            ArgData ad = (ArgData)arg;

            if (ad.negated)
            {
                ad.clauses.Get(ad.clauses.Size() - 1).addNegativeLiteral(equality);
            }
            else
            {
                ad.clauses.Get(ad.clauses.Size() - 1).addPositiveLiteral(equality);
            }
            return(equality);
        }
Exemple #7
0
        public object visitPredicate(Predicate p, object arg)
        {
            ArgData ad = (ArgData)arg;

            if (ad.negated)
            {
                ad.clauses.Get(ad.clauses.Size() - 1).addNegativeLiteral(p);
            }
            else
            {
                ad.clauses.Get(ad.clauses.Size() - 1).addPositiveLiteral(p);
            }
            return(p);
        }
Exemple #8
0
        public object VisitPredicate(Predicate p, object arg)
        {
            ArgData ad = (ArgData)arg;

            if (ad.Negated)
            {
                ad.Clauses[ad.Clauses.Count - 1].AddNegativeLiteral(p);
            }
            else
            {
                ad.Clauses[ad.Clauses.Count - 1].AddPositiveLiteral(p);
            }
            return(p);
        }
Exemple #9
0
        public object VisitConnectedSentence(ConnectedSentence sentence, object arg)
        {
            ArgData   ad     = (ArgData)arg;
            ISentence first  = sentence.First;
            ISentence second = sentence.Second;

            first.Accept(this, arg);
            if (Connectors.IsAnd(sentence.Connector))
            {
                ad.Clauses.Add(new Clause());
            }
            second.Accept(this, arg);

            return(sentence);
        }
Exemple #10
0
        public Object visitConnectedSentence(ConnectedSentence sentence, Object arg)
        {
            ArgData  ad     = (ArgData)arg;
            Sentence first  = sentence.getFirst();
            Sentence second = sentence.getSecond();

            first.accept(this, arg);
            if (Connectors.isAND(sentence.getConnector()))
            {
                ad.clauses.Add(new Clause());
            }
            second.accept(this, arg);

            return(sentence);
        }
        /// <summary>
        /// Collects a property of a tool across across multiple property sheets
        /// with inheritance (i.e. respecting $(Inherit) and $(NoInherit) macros).
        /// </summary>
        /// <param name="configuration">The project configuration.</param>
        /// <param name="toolName">The name of the tool, e.g. "VCCLCompilerTool".</param>
        /// <param name="propGetter">The getter that retrieves the property.</param>
        /// <remarks>
        /// This method tries to emulate Visual Studio, since the Extensibility API
        /// doesn't seem to provide anything like this.
        /// </remarks>
        static public List <string> Get(VCConfiguration configuration, string toolName, PropertyGetter propGetter)
        {
            ArgData data = new ArgData();

            data.conf       = configuration;
            data.sheets     = Utils.call(() => (data.conf.PropertySheets as IVCCollection));
            data.numSheets  = Utils.call(() => (data.sheets.Count));
            data.toolName   = toolName;
            data.propGetter = propGetter;
            data.result     = new List <string>();

            _Get(data, 0);

            return(data.result);
        }
 public Action CopyFromStackToFrame(ArgData arg) => () =>
 {
     var elementSize = arg.Elements.Count;
     Global.Compiler.TypePop();
     if (elementSize == 1)
     {
         Global.Emit(StackPop, arg.Offset, Opcode.STY);
     }
     else
     {
         Global.Emit(Opcode.PUY, arg.Offset, Opcode.AKA,      // Destination
                     Opcode.PUX, 1 - elementSize, Opcode.AKA, // Source
                     elementSize, Opcode.PSH,                 // Size
                     Opcode.MFD,
                     -elementSize, Opcode.AKX);
     }
 };
        public Action CopyFromFrameToStack(ArgData arg) => () =>
        {
            var elementSize = arg.Elements.Count;
            Global.Compiler.TypePush(arg.Type);

            if (elementSize == 1)
            {
                Global.Emit(arg.Offset, Opcode.LDY, StackPush);
            }
            else
            {
                Global.Emit(elementSize, Opcode.AKX,
                            1 - elementSize, Opcode.PUX, // Destination
                            arg.Offset, Opcode.PUY,      // Source
                            elementSize, Opcode.PSH,     // Size
                            Opcode.MFD);
            }
        };
Exemple #14
0
        private void LoadNextStackDataLayer()
        {
            uint ProcessId = GetSelectedProcessId();

            foreach (VariableData ArgData in ArgumentDatas)
            {
                ArgData.LoadFields(TheDebugger, ProcessId, ArgumentsDepthLoaded);
            }
            ArgumentsDepthLoaded++;

            foreach (VariableData LocData in LocalDatas)
            {
                LocData.LoadFields(TheDebugger, ProcessId, LocalsDepthLoaded);
            }
            LocalsDepthLoaded++;

            UpdateStackData();

            PerformingAction = false;
        }
        /// <summary>
        /// Helper method that gets the tool object.
        /// </summary>
        static private object GetTool(ArgData data, int sheetIndex)
        {
            if (sheetIndex >= data.numSheets)
            {
                return(null); // reached the last sheet
            }
            else
            {
                IVCCollection tools;
                if (sheetIndex == 0)
                {
                    // get the tools of the VCConfiguration itself (top level)
                    tools = Utils.call(() => (data.conf.Tools as IVCCollection));
                }
                else
                {
                    // get the tools of the Nth property sheet
                    VCPropertySheet sheet = Utils.call(() => (data.sheets.Item(sheetIndex) as VCPropertySheet));
                    tools = Utils.call(() => (sheet.Tools as IVCCollection));
                }

                return(Utils.call(() => tools.Item(data.toolName)));
            }
        }
        /// <summary>
        /// Collects a property of a tool across across multiple property sheets
        /// with inheritance (i.e. respecting $(Inherit) and $(NoInherit) macros).
        /// </summary>
        /// <param name="configuration">The project configuration.</param>
        /// <param name="toolName">The name of the tool, e.g. "VCCLCompilerTool".</param>
        /// <param name="propGetter">The getter that retrieves the property.</param>
        /// <remarks>
        /// This method tries to emulate Visual Studio, since the Extensibility API
        /// doesn't seem to provide anything like this.
        /// </remarks>
        public static List<string> Get(VCConfiguration configuration, string toolName, PropertyGetter propGetter)
        {
            ArgData data = new ArgData();
            data.conf = configuration;
            data.sheets = Utils.call(() => (data.conf.PropertySheets as IVCCollection));
            data.numSheets = Utils.call(() => (data.sheets.Count));
            data.toolName = toolName;
            data.propGetter = propGetter;
            data.result = new List<string>();

            _Get(data, 0);

            return data.result;
        }
        /// <summary>
        /// Helper method that does the actual job -- calls <see cref="_Get"/> recursively
        /// as needed.
        /// </summary>
        private static void _Get(ArgData data, int sheetIndex)
        {
            if (sheetIndex > data.numSheets) // sheet indices are 1-based
                return; // past last sheet

            object tool = GetTool(data, sheetIndex);
            if (tool == null)
            {
                // This property sheet has no settings for this tool,
                // but perhaps the next one has.
                _Get(data, sheetIndex + 1);
                return;
            }

            List<string> list = data.propGetter(tool);
            if (list == null)
            {
                // This property sheet isn't customizing this particular setting,
                // but perhaps the next one does.
                _Get(data, sheetIndex + 1);
                return;
            }

            // If $(NoInherit) appears anywhere within the property, inheritance stops
            // right here, and even implicit $(Inherit) will be ignored.
            bool noInherit = list.Contains("$(NoInherit)");

            // Look for $(Inherit) elements and run recursively
            bool explicitInherit = false;
            foreach (string item in list)
            {
                if (!noInherit && item == "$(Inherit)")
                {
                    explicitInherit = true;
                    _Get(data, sheetIndex + 1); // inherit from next sheet
                }
                else
                {
                    data.result.Add(item);
                }
            }

            // If there was no explicit $(Inherit) anywhere in the property,
            // we "append" an implicit one at the end.
            if (!noInherit && !explicitInherit)
            {
                _Get(data, sheetIndex + 1); // inherit from next sheet
            }
        }
        /// <summary>
        /// Helper method that gets the tool object.
        /// </summary>
        private static object GetTool(ArgData data, int sheetIndex)
        {
            if (sheetIndex >= data.numSheets)
            {
                return null; // reached the last sheet
            }
            else
            {
                IVCCollection tools;
                if (sheetIndex == 0)
                {
                    // get the tools of the VCConfiguration itself (top level)
                    tools = Utils.call(() => (data.conf.Tools as IVCCollection));
                }
                else
                {
                    // get the tools of the Nth property sheet
                    VCPropertySheet sheet = Utils.call(() => (data.sheets.Item(sheetIndex) as VCPropertySheet));
                    tools = Utils.call(() => (sheet.Tools as IVCCollection));
                }

                return Utils.call(() => tools.Item(data.toolName));
            }
        }
Exemple #19
0
        public CNF construct(Sentence orDistributedOverAnd)
        {
            ArgData ad = new ArgData();

            orDistributedOverAnd.accept(this, ad);

            return new CNF(ad.clauses);
        }