예제 #1
0
        public static void InitializePredefinedTypes(Symtab pSymtab)
        {
            SymtabNode pIntegerId = pSymtab.Enter("integer", TDefnCode.dcType);
            SymtabNode pRealId = pSymtab.Enter("real", TDefnCode.dcType);
            SymtabNode pBooleanId = pSymtab.Enter("boolean", TDefnCode.dcType);
            SymtabNode pCharId = pSymtab.Enter("char", TDefnCode.dcType);
            SymtabNode pFalseId = pSymtab.Enter("false", TDefnCode.dcType);
            SymtabNode pTrueId = pSymtab.Enter("true", TDefnCode.dcType);

            if (pIntegerType == null)
            {
                SetType(ref pIntegerType, new TType(TFormCode.fcScalar, sizeof(int), pIntegerId));
            }
            if (pRealType == null)
            {
                SetType(ref pRealType,
                    new TType(TFormCode.fcScalar, sizeof(float), pRealId));
            }
            if (pBooleanType == null)
            {
                SetType(ref pBooleanType,
                    new TType(TFormCode.fcEnum, sizeof(int), pBooleanId));
            }
            if (pCharType == null)
            {
                SetType(ref pCharType,
                    new TType(TFormCode.fcScalar, sizeof(char), pCharId));
            }

            //--Link each predefined type's id node to its type object.
            SetType(ref pIntegerId.pType, pIntegerType);
            SetType(ref pRealId.pType, pRealType);
            SetType(ref pBooleanId.pType, pBooleanType);
            SetType(ref pCharId.pType, pCharType);

            //--More initialization for the boolean type object.
            pBooleanType.Enumeration.max = 1;        // max value
            pBooleanType.Enumeration.ConstIds = pFalseId; // first constant

            //--More initialization for the "false" and "true" id nodes.
            pFalseId.defn.constantValue.integerValue = 0;
            pTrueId.defn.constantValue.integerValue = 1;
            SetType(ref pTrueId.pType, pBooleanType);
            SetType(ref pFalseId.pType, pBooleanType);
            pFalseId.Next = pTrueId;  // "false" node points to "true" node

            //--Initialize the dummy type object that will be used
            //--for erroneous type definitions and for typeless objects.
            SetType(ref pDummyType, new TType(TFormCode.fcNone, 1, null));
        }
예제 #2
0
        private void InitializeStandardRoutines(Symtab pSymtab)
        {
            foreach (TStdRtn pSR in stdRtnList)
            {
                SymtabNode pRoutineId = pSymtab.Enter(pSR.pName, pSR.dc);

                pRoutineId.defn.routine.which = pSR.rc;
                pRoutineId.defn.routine.parmCount = 0;
                pRoutineId.defn.routine.totalParmSize = 0;
                pRoutineId.defn.routine.totalLocalSize = 0;
                pRoutineId.defn.routine.locals.pParmIds = null;
                pRoutineId.defn.routine.locals.pConstantIds = null;
                pRoutineId.defn.routine.locals.pTypeIds = null;
                pRoutineId.defn.routine.locals.pVariableIds = null;
                pRoutineId.defn.routine.locals.pRoutineIds = null;
                pRoutineId.defn.routine.pSymtab = null;
                pRoutineId.defn.routine.pIcode = null;
                TType.SetType(ref pRoutineId.pType, TType.pDummyType);
            }
        }