Core: Minor changes with ValueTypeError, Skylark: Fixed issue with witz error line number

git-svn-id: svn://ultimatepp.org/upp/trunk@7243 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-04-13 18:44:34 +00:00
parent 592008a677
commit ca1a7bf19a
5 changed files with 17 additions and 24 deletions

View file

@ -790,3 +790,9 @@ inline void __LOGF__(const char *format, ...);
template <class T>
void IGNORE_RESULT(const T&) {}
class Exc : public String {
public:
Exc() {}
Exc(const String& desc) : String(desc) {}
};

View file

@ -8,14 +8,8 @@ const Nuller Null;
#define LTIMING(x) // RTIMING(x)
void ThrowValueTypeError(const String& text, const Value& src, int target)
{
ValueTypeError err;
(String&)err = text;
err.src = text;
err.target = target;
throw err;
}
ValueTypeError::ValueTypeError(const String& text, const Value& src, int target)
: Exc(text), src(src), target(target) {}
unsigned Value::GetOtherHashValue() const {
if(IsNull())

View file

@ -74,14 +74,6 @@ class AssignValueTypeNo : public ValueType<T, type, B> {};
template <class T>
dword GetValueTypeNo() { return ValueTypeNo((T*)NULL); }
class Exc : public String {
public:
Exc() {}
Exc(const String& desc) : String(desc) {}
};
void ThrowValueTypeError(const String& text, const Value& src, int target);
class Value : Moveable_<Value> {
public:
class Void {
@ -271,6 +263,8 @@ public:
struct ValueTypeError : Exc {
Value src;
int target;
ValueTypeError(const String& text, const Value& src, int target);
};
template <class T> bool FitsSvoValue() { return sizeof(T) <= 8; }

View file

@ -204,9 +204,9 @@ T& Value::GetSmall() const
ASSERT(t < 255);
if(Is((byte)t))
return GetSmallRaw<T>();
ThrowValueTypeError(String().Cat() << "Invalid value conversion: "
<< GetName() << " -> " << typeid(T).name(),
*this, t);
throw ValueTypeError(String().Cat() << "Invalid value conversion: "
<< GetName() << " -> " << typeid(T).name(),
*this, t);
return *(T*)&data; // Silence compiler warning
}
@ -249,10 +249,9 @@ inline const T& Value::To() const
if(Is((byte)t))
return GetSmallRaw<T>();
}
ThrowValueTypeError(String().Cat() << "Invalid value conversion: "
<< GetName() << " -> " << typeid(T).name(),
*this, t);
return *(T*)&data; // Silence compiler warning
throw ValueTypeError(String().Cat() << "Invalid value conversion: "
<< GetName() << " -> " << typeid(T).name(),
*this, t);
}
template <class T>

View file

@ -356,7 +356,7 @@ One<Exe> Compiler::Block()
ExeBlock& blk = result.Create<ExeBlock>();
const char *s = p.GetSpacePtr();
const char *b = s;
int line = 1;
int line = p.GetLine();
while(*s) {
if(*s == '$') {
if(s[1] == '$') {