Просмотр исходного кода

переформатировал

p.kushnir 10 лет назад
Родитель
Сommit
ca09acf6aa
5 измененных файлов с 45 добавлено и 51 удалено
  1. 1 1
      lib/fib.dart
  2. 6 6
      lib/nons.dart
  3. 25 27
      lib/trits.dart
  4. 5 5
      web/index.html
  5. 8 12
      web/main.dart

+ 1 - 1
lib/fib.dart

@@ -188,4 +188,4 @@ part of tri;
 BEGIN
   Init
 END TRiscTernS.
-*/
+*/

+ 6 - 6
lib/nons.dart

@@ -90,11 +90,11 @@ class Nons {
   END Load9;
   
    */
-  static String intToString(int27 i){
-    
+  static String intToString(int27 i) {
+
   }
-  
-  static int27 parse(String s){
-    
+
+  static int27 parse(String s) {
+
   }
-}
+}

+ 25 - 27
lib/trits.dart

@@ -32,7 +32,7 @@ class Bits {
     }
     return ret;
   }
-  
+
   /*
    *  PROCEDURE (VAR s: Set) And* (t: Set), NEW;
     VAR i: Tryte; z: Set; a, b: TRiscTern.Trilean;
@@ -98,22 +98,22 @@ class Bits {
     s.pos:=z.pos;
   END Div;
    */
-  Bits operator +(Bits that){
-    
+  Bits operator +(Bits that) {
+
   }
-  
-  Bits operator *(Bits that){
-    
+
+  Bits operator *(Bits that) {
+
   }
-  
-  Bits operator -(Bits that){
-    
+
+  Bits operator -(Bits that) {
+
   }
-  
-  Bits operator /(Bits that){
-    
+
+  Bits operator /(Bits that) {
+
   }
-  
+
   Bits extract(int from, int to) {
     Bits ret = new Bits._new();
     if (from >= _trits.length || to > _trits.length) throw new ArgumentError("$from, $to");
@@ -122,32 +122,30 @@ class Bits {
     }
     return ret;
   }
-  
-  Bits join(Bits that){
+
+  Bits join(Bits that) {
     Bits ret = new Bits._new();
-    for(int i = 1; i<28; i++){
-      if(this[i] != NULL)
-        ret = ret.incl(i*this[i].toInt);
-      if(that[i] != NULL)
-        ret = ret.incl(i*that[i].toInt);
+    for (int i = 1; i < 28; i++) {
+      if (this[i] != NULL) ret = ret.incl(i * this[i].toInt);
+      if (that[i] != NULL) ret = ret.incl(i * that[i].toInt);
     }
     return ret;
   }
-  
-  Bits incl(int x){
+
+  Bits incl(int x) {
     if (x == 0 || x.abs() > 27) throw new ArgumentError("$x");
     Bits ret = this.extract(0, 27);
-    ret._trits[x.abs()-1] = new Tril.fromInt(x.sign);
+    ret._trits[x.abs() - 1] = new Tril.fromInt(x.sign);
     return ret;
   }
-  
-  Bits excl(int x){
+
+  Bits excl(int x) {
     if (x == 0 || x.abs() > 27) throw new ArgumentError("$x");
     Bits ret = this.extract(0, 27);
-    ret._trits[x.abs()-1] = NULL;
+    ret._trits[x.abs() - 1] = NULL;
     return ret;
   }
-  
+
   Tril operator [](int x) {
     if (x == 0 || x.abs() > 27) throw new ArgumentError("$x");
     Tril ret = _trits[x.abs() - 1];

+ 5 - 5
web/index.html

@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
 <head>
-    <meta charset="utf-8">
-    <title>tri</title>
+<meta charset="utf-8">
+<title>tri</title>
 </head>
 <body>
-TRI
-<script type="application/dart" src="main.dart"></script>
-<script data-pub-inline src="packages/browser/dart.js"></script>
+	TRI
+	<script type="application/dart" src="main.dart"></script>
+	<script data-pub-inline src="packages/browser/dart.js"></script>
 </body>
 </html>

+ 8 - 12
web/main.dart

@@ -4,7 +4,7 @@ import 'package:tri/mathe.dart';
 void main() {
   print("$TRUE, $NULL, $FALSE");
 
-  test("basics", (){
+  test("basics", () {
     expect(TRUE, equals(TRUE));
     expect(FALSE, equals(FALSE));
     expect(NULL, isNot(equals(TRUE)));
@@ -14,7 +14,7 @@ void main() {
     expect(new Tril.fromInt(0), equals(NULL));
   });
 
-  test("logic", (){
+  test("logic", () {
     expect(TRUE | TRUE, equals(TRUE));
     expect(FALSE & FALSE, equals(FALSE));
   });
@@ -24,24 +24,20 @@ void main() {
   print(int27.min);
   print(int27.max);
 
-  test("arithmetics", (){
-    expect(new tryte(5)+new tryte.one(), equals(new tryte(6)));
+  test("arithmetics", () {
+    expect(new tryte(5) + new tryte.one(), equals(new tryte(6)));
     expect(short(new int27(40)), equals(new tryte(40)));
   });
 
-  test("bits", (){
+  test("bits", () {
     expect(new Bits(int27.max).toString(), equals("+++++++++++++++++++++++++++"));
     expect(new Bits(tryte.max).toString(), equals("000000000000000000+++++++++"));
     expect(tryte.max, equals(short(new Bits(tryte.max).toInt27())));
     expect(int27.max, equals(new Bits(int27.max).toInt27()));
     expect(new Bits(new tryte(1)) << 5, equals((new Bits(new tryte(1)) << 18) >> 13));
-    expect(new int27(1) << 5, equals((new int27(1) << 18) >>13));
-    expect(new tryte(1) << 5, isNot(equals((new tryte(1) << 18) >>13)));
+    expect(new int27(1) << 5, equals((new int27(1) << 18) >> 13));
+    expect(new tryte(1) << 5, isNot(equals((new tryte(1) << 18) >> 13)));
     expect(new Bits(new tryte(5))[1], equals(~(new Bits(new tryte(-5))[1])));
-    expect(
-          new Bits(new tryte(0)).incl(5).incl(8).incl(-1).excl(-1),
-          equals(
-            new Bits(new tryte(0)).incl(5).join(new Bits(new tryte(0)).incl(8))    
-          ));
+    expect(new Bits(new tryte(0)).incl(5).incl(8).incl(-1).excl(-1), equals(new Bits(new tryte(0)).incl(5).join(new Bits(new tryte(0)).incl(8))));
   });
 }