Exemple #1
0
        public string ConvertArrayNode(ArrayNode anode, Dictionary <string, int> dict)
        {
            string code = converter.ConvertToCode(converter.Convert(anode.index, dict) + "\t ; eax = index",
                                                  "shl eax, 2" + "\t ; index = index  * 4",
                                                  "mov dword ecx, " + converter.ConvertName(anode.identifier, dict),
                                                  "add ecx, eax",
                                                  "mov dword eax, [ecx]");

            return(code);
        }
        public type GetType(ArrayNode anode, Environment env)
        {
            type t1 = GetType(anode.index, env);

            if (!IsFixedNumericType(t1))
            {
                throw new Exception("Array lookup for " + anode.identifier + "is not a fixed int.");
            }

            ArrayType atype = (ArrayType)env.GetType(anode.identifier);

            return(atype.variableType);
        }
 public string Print(ArrayNode anode)
 {
     return(anode.identifier + "[" + Print(anode.index) + "]");
 }