summaryrefslogtreecommitdiff
path: root/projects/12/Array.jack
blob: c712b69c2605bd77bd4cb3e312b0d4df6650f2d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/12/Array.jack

/**
 * Represents an array.
 * In the Jack language, arrays are instances of the Array class.
 * Once declared, the array entries can be accessed using the usual
 * syntax arr[i]. Each array entry can hold a primitive data type as 
 * well as any object type. Different array entries can have different 
 * data types.
 */
class Array {

    /** Constructs a new Array of the given size. */
    function Array new(int size) {
        return Memory.alloc(size);
    }

    /** Disposes this array. */
    method void dispose() {
        return Memory.deAlloc(this);
    }
}