Example #1
0
        private static void Ifndef(CodeProcessorContext context, ConditionToken token, List <FileDescriptor> referenceFiles, List <string> fileLookups, TokenStream nodes)
        {
            int bytes;

            Preprocessor.CheckState(context, nodes, (byte)((context.Definitions.ContainsKey(token.Condition.DecodeUInt32(out bytes))) ? 1 : 0));

            if (nodes.CanWrite && token.Child != null)
            {
                GetResult(context, token.Child as PreprocessorToken, referenceFiles, fileLookups, nodes);
            }

            EndCondition(context, token.Next, nodes);
        }
Example #2
0
        private static void Else(CodeProcessorContext context, List <FileDescriptor> referenceFiles, List <string> fileLookups, PreprocessorToken token, TokenStream nodes)
        {
            int result = context.States.Pop();

            if (result >= 4)
            {
                result = 2;
            }

            Preprocessor.CheckState(context, nodes, result);

            if (nodes.CanWrite && token.Child != null)
            {
                GetResult(context, token.Child as PreprocessorToken, referenceFiles, fileLookups, nodes);
            }

            EndCondition(context, null, nodes);
        }
Example #3
0
        private static void If(CodeProcessorContext context, ConditionToken token, List <FileDescriptor> referenceFiles, List <string> fileLookups, TokenStream nodes, bool useExistingState)
        {
            TokenStream expression         = new TokenStream();
            Lazy <HashSet <UInt32> > stack = new Lazy <HashSet <UInt32> >();

            while (!Preprocessor.LineBreak(context, token.Condition, expression))
            {
                Preprocessor.ProcessNoComments(context, token.Condition, expression, stack, true);
            }

            int result; if (useExistingState)

            {
                result = context.States.Pop();
            }

            else
            {
                result = 0;
            }

            if (result >= 4)
            {
                result = 2;
            }

            result |= (PreprocessorEvaluator.Evaluate(expression) ? 0 : 1);
            Preprocessor.CheckState(context, nodes, result);

            if (nodes.CanWrite && token.Child != null)
            {
                GetResult(context, token.Child as PreprocessorToken, referenceFiles, fileLookups, nodes);
            }

            EndCondition(context, token.Next, nodes);
        }