Esempio n. 1
0
        public string ConvertArrayCreationNode(ArrayCreationNode acn, Dictionary <string, int> dict)
        {
            Func <string, string, string> f = (x, y) => x + "\t ; " + y;

            string code = converter.ConvertToCode(converter.Convert(acn.size, dict)
                                                  + "\t \t ; length of array",
                                                  f("mov ecx, [heapIndex]", "ecx = current position in heap"),
                                                  "shl eax, 2" + "\t \t ; length = length * 4",
                                                  "add ecx, eax" + "\t \t ; ecx = position + length * 4 ",
                                                  f("mov eax, [heapIndex]", "eax = heapIndex"),
                                                  f("mov [heapIndex], ecx", "heapIndex = ecx"));

            return(code);
        }
Esempio n. 2
0
 public string StandardBinaryOperation(BinaryOperationNode bnode, Dictionary <string, int> variableIndex)
 {
     return(converter.ConvertToCode(converter.Convert(bnode.right, variableIndex), "push eax"
                                    , converter.Convert(bnode.left, variableIndex), "pop ecx"));
 }