Example #1
0
        public static void LogicOperator()
        {
            SAR    y  = SAS.Pop();
            SAR    x  = SAS.Pop();
            SAR    z  = new SAR(SAR.SARtype.Identifier, x.token, x.value, x.scope);
            string op = OS.Peek();

            if ((x.dataType != y.dataType) || (x.dataType != "bool"))
            {
                SemanticOperationError(x, y, OS.Pop());
            }
            z.symid    = "t" + uniqueCounter++;
            z.value   += "_" + y.value;
            z.scope    = "t";
            z.dataType = "bool";
            string[] data = { "returnType:" + z.dataType, "accessMod:private" };
            Symbol   temp = new Symbol("t", z.symid, z.value, "tvar", data);

            SymbolTable.Add(temp);
            if (op == "and")
            {
                ICode.AND(x.symid, y.symid, z.symid);
            }
            else if (op == "or")
            {
                ICode.OR(x.symid, y.symid, z.symid);
            }
            SAS.Push(z);
            OS.Pop();
            OSprecidence.Pop();
            return;
        }