فهرست منبع

added : base.

Nicolas Cannasse 20 سال پیش
والد
کامیت
58d6dc8a87
4فایلهای تغییر یافته به همراه96 افزوده شده و 0 حذف شده
  1. 21 0
      std/Array.hx
  2. 45 0
      std/List.hx
  3. 17 0
      std/Std.hx
  4. 13 0
      std/String.hx

+ 21 - 0
std/Array.hx

@@ -0,0 +1,21 @@
+package {
+
+native class Array<T> {
+
+	public var length : Int;
+
+	public function new() { }
+	function push(x : T) : Void { }
+	function pop() : T { }
+	function unshift( x : T ) : Void { }
+
+	function join( sep : String ) : String { }
+	function toString() : String { }
+
+	function sort( f : T -> T -> Int ) : Void { }
+	function insert( pos : Int, x : T ) : Void { }
+
+
+}
+
+}

+ 45 - 0
std/List.hx

@@ -0,0 +1,45 @@
+package {
+
+enum Cell<T> {
+	empty;
+	cons( item : T, next : Cell<T> );
+};
+
+class List<T> {
+
+	private var h : Cell<T>;
+
+	public function new() {
+		h = empty;
+	}
+
+	public function push( item : T ) : Void {
+		h = cons(item,h);
+	}
+
+	public function pop() : T {
+		return switch h {
+		case empty:
+			null;
+		case cons(it,h):
+			this.h = h;
+			it;
+		}
+	}
+
+	public function iterator() : Void -> T {
+		var h = this.h;
+		return function() {
+			return switch h {
+			case empty:
+				done;
+			case cons(it,next):
+				h = next;
+				it;
+			}
+		};
+	}
+
+}
+
+}

+ 17 - 0
std/Std.hx

@@ -0,0 +1,17 @@
+package {
+
+enum Void { }
+
+native class Float { }
+
+native class Int extends Float { }
+
+enum Bool {
+	true;
+	false;
+}
+
+enum Dynamic<T> {
+}
+
+}

+ 13 - 0
std/String.hx

@@ -0,0 +1,13 @@
+package {
+
+native class String {
+
+	public var length : Int;
+
+	public function new( s : String ) { }
+	public function sub( p : Int, l : Int) : String { }
+	public function split( s : String ) : Array<String> { }
+
+}
+
+}