예제 #1
0
        public static void new_arr()
        {
            SAR exp  = SAS.Pop();
            SAR type = SAS.Pop();

            if (exp.dataType != "int")
            {
                SemanticArrError(type, exp);
            }
            if (type.value == "null")
            {
                SemanticArrError(type, exp);
            }
            string[] data1 = { "returnType:int", "accessMod:private" };
            Symbol   size  = new Symbol("t", "t" + uniqueCounter++, "t" + type.value, "tvar", data1);

            SymbolTable.Add(size);
            string[] data = { "returnType:" + "@" + type.value, "accessMod:private" };
            Symbol   temp = new Symbol("t", "t" + uniqueCounter++, "t" + type.value, "tvar", data);

            SymbolTable.Add(temp);
            type.symid = temp.symid;
            int classSize = SymbolTable.GetValue(type.symid).size;

            string[] sizeData    = { "returnType:int", "accessMod:public" };
            Symbol   sizeLiteral = new Symbol("g", "N4", "4", "ilit", sizeData);

            SymbolTable.Add(sizeLiteral);
            ICode.MUL(sizeLiteral.symid, exp.symid, size.symid);
            ICode.NEW(size.symid, type.symid);
            type.dataType = "@" + type.value;
            SAS.Push(type);
        }