public type GetType(ArrayCreationNode arrayCreationNode, Environment env) { if (!IsFixedNumericType(GetType(arrayCreationNode.size, env))) { throw new Exception("array length must be of fixed numeric size"); } var type = TypeNodeToType(arrayCreationNode.primitiveTypeNode, env); return(new ArrayType((VariableType)type)); }
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); }