Mercurial Hosting > luan
comparison core/src/luan/modules/PickleCon.java @ 578:60c549d43988
remove LuanState.exception()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 14 Jul 2015 17:40:48 -0600 |
parents | 7c3ad6db8ac3 |
children |
comparison
equal
deleted
inserted
replaced
577:d7a85fbe15f1 | 578:60c549d43988 |
---|---|
46 byte[] a = new byte[size]; | 46 byte[] a = new byte[size]; |
47 int i = 0; | 47 int i = 0; |
48 while( i < size ) { | 48 while( i < size ) { |
49 int n = in.read(a,i,size-i); | 49 int n = in.read(a,i,size-i); |
50 if( n == -1 ) | 50 if( n == -1 ) |
51 // throw luan.exception( "end of stream" ); | 51 // throw new LuanException(luan, "end of stream" ); |
52 throw new EOFException(); | 52 throw new EOFException(); |
53 i += n; | 53 i += n; |
54 } | 54 } |
55 return a; | 55 return a; |
56 } | 56 } |
81 if( obj instanceof byte[] ) { | 81 if( obj instanceof byte[] ) { |
82 byte[] a = (byte[])obj; | 82 byte[] a = (byte[])obj; |
83 binaries.add(a); | 83 binaries.add(a); |
84 return "_binaries[" + binaries.size() + "]"; | 84 return "_binaries[" + binaries.size() + "]"; |
85 } | 85 } |
86 throw luan.exception( "invalid type: " + obj.getClass() ); | 86 throw new LuanException(luan, "invalid type: " + obj.getClass() ); |
87 } | 87 } |
88 | 88 |
89 private String pickle(Object obj,Set<LuanTable> set) throws LuanException { | 89 private String pickle(Object obj,Set<LuanTable> set) throws LuanException { |
90 return obj instanceof LuanTable ? pickle((LuanTable)obj,set) : pickle(obj); | 90 return obj instanceof LuanTable ? pickle((LuanTable)obj,set) : pickle(obj); |
91 } | 91 } |
92 | 92 |
93 private String pickle(LuanTable tbl,Set<LuanTable> set) throws LuanException { | 93 private String pickle(LuanTable tbl,Set<LuanTable> set) throws LuanException { |
94 if( !set.add(tbl) ) { | 94 if( !set.add(tbl) ) { |
95 throw luan.exception( "circular reference in table" ); | 95 throw new LuanException(luan, "circular reference in table" ); |
96 } | 96 } |
97 StringBuilder sb = new StringBuilder(); | 97 StringBuilder sb = new StringBuilder(); |
98 sb.append( "{" ); | 98 sb.append( "{" ); |
99 for( Map.Entry<Object,Object> entry : tbl.iterable(luan) ) { | 99 for( Map.Entry<Object,Object> entry : tbl.iterable(luan) ) { |
100 sb.append( "[" ); | 100 sb.append( "[" ); |