From d3a0cc3a8ba6dfeb64d3faeffdeb6845b60e5840 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 20 Jan 2018 15:41:49 +0100 Subject: rearranged the dir for github - removed tools and pdfs - rearranged the projects dirs - added md files - other minor changes --- jackos/Array.jack | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 jackos/Array.jack (limited to 'jackos/Array.jack') diff --git a/jackos/Array.jack b/jackos/Array.jack new file mode 100644 index 0000000..343c25c --- /dev/null +++ b/jackos/Array.jack @@ -0,0 +1,26 @@ +// 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() { + do Memory.deAlloc(this); + return; + } +} -- cgit v1.2.3