Files
sdk/runtime/vm/exceptions.h
T
turnidge@google.com e61a02c10d Implement spawnFunction from the new isolate api.
Still need to implement spawnUri, which will be the more difficult one.
Review URL: https://chromiumcodereview.appspot.com//9691005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@5441 260f80e4-7a28-3924-810f-c04153c831b5
2012-03-13 22:05:08 +00:00

78 lines
2.3 KiB
C++

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef VM_EXCEPTIONS_H_
#define VM_EXCEPTIONS_H_
#include "vm/allocation.h"
#include "vm/growable_array.h"
namespace dart {
// Forward declarations.
class Class;
class DartFrameIterator;
class Error;
class Instance;
class Object;
class RawInstance;
class RawScript;
class RawObject;
class Script;
class String;
class Exceptions : AllStatic {
public:
static void Throw(const Instance& exception);
static void ReThrow(const Instance& exception, const Instance& stacktrace);
static void PropagateError(const Object& obj);
// Helpers to create and throw errors.
static RawScript* GetCallerScript(DartFrameIterator* iterator);
static RawInstance* NewInstance(const char* class_name);
static void SetField(const Instance& instance,
const Class& cls,
const char* field_name,
const Object& value);
static void SetLocationFields(const Instance& instance,
const Class& cls,
const Script& script,
intptr_t location);
static void CreateAndThrowTypeError(intptr_t location,
const String& src_type_name,
const String& dst_type_name,
const String& dst_name,
const String& malformed_error);
enum ExceptionType {
kIndexOutOfRange,
kIllegalArgument,
kNoSuchMethod,
kClosureArgumentMismatch,
kObjectNotClosure,
kBadNumberFormat,
kStackOverflow,
kOutOfMemory,
kWrongArgumentCount,
kInternalError,
kNullPointer,
kIllegalJSRegExp,
kIsolateSpawn
};
static void ThrowByType(ExceptionType type,
const GrowableArray<const Object*>& arguments);
// Returns a RawInstance if the exception is successfully created,
// otherwise returns a RawError.
static RawObject* Create(ExceptionType type,
const GrowableArray<const Object*>& arguments);
private:
DISALLOW_COPY_AND_ASSIGN(Exceptions);
};
} // namespace dart
#endif // VM_EXCEPTIONS_H_