bf67f24098
The purpose of this change is twofold: 1. Source in the bin directory can now use the same assertions as source in the vm directory. The ASSERT macro used by the code in runtime/bin was just defined to use assert from the standard C library. 2. Moving other implementation parts from runtime/vm to runtime/platform (e.g. classes Monitor and Mutex) for sharing between runtime/bin and runtime/vm will be easier as these implementations rely on these assertion macros. Created two gypi files for the platform directory. One for the headers and one for the source. The source one is only included when building the VM library and will be present in libdart.a when the dart executable is linked. All the code for asserts is still in the dart namespace. Also re-arranged the order of includes to be alphabetically in the files touched. R=ager@google.com, iposva@google.com BUG= TEST= Review URL: http://codereview.chromium.org//9189003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3335 260f80e4-7a28-3924-810f-c04153c831b5
65 lines
2.2 KiB
C++
65 lines
2.2 KiB
C++
// Copyright (c) 2012, 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_NATIVE_ARGUMENTS_H_
|
|
#define VM_NATIVE_ARGUMENTS_H_
|
|
|
|
#include "platform/assert.h"
|
|
#include "vm/globals.h"
|
|
|
|
namespace dart {
|
|
|
|
// Forward declarations.
|
|
class Isolate;
|
|
class Object;
|
|
class RawObject;
|
|
|
|
|
|
// Class NativeArguments is used to access arguments passed in from
|
|
// generated dart code to a runtime function or a dart library native
|
|
// function. It is also used to set the return value if any at the slot
|
|
// reserved for return values.
|
|
// All runtime function/dart library native functions have the
|
|
// following signature:
|
|
// void function_name(NativeArguments arguments);
|
|
// Inside the function, arguments are accessed as follows:
|
|
// const Type& arg1 = Type::CheckedHandle(arguments.GetArgument(0));
|
|
// const Type& arg2 = Type::CheckedHandle(arguments.GetArgument(1));
|
|
// The return value is set as follows:
|
|
// arguments.SetReturnValue(result);
|
|
// NOTE: Since we pass this as a pass by value argument in the stubs we don't
|
|
// have DISALLOW_COPY_AND_ASSIGN in the class definition and do not make it a
|
|
// subclass of ValueObject.
|
|
class NativeArguments {
|
|
public:
|
|
Isolate* isolate() const { return isolate_; }
|
|
int Count() const { return argc_; }
|
|
|
|
RawObject* At(int index) const {
|
|
ASSERT(index >=0 && index < argc_);
|
|
return (*argv_)[-index];
|
|
}
|
|
|
|
void SetReturn(const Object& value) const;
|
|
|
|
static intptr_t isolate_offset() {
|
|
return OFFSET_OF(NativeArguments, isolate_);
|
|
}
|
|
static intptr_t argc_offset() { return OFFSET_OF(NativeArguments, argc_); }
|
|
static intptr_t argv_offset() { return OFFSET_OF(NativeArguments, argv_); }
|
|
static intptr_t retval_offset() {
|
|
return OFFSET_OF(NativeArguments, retval_);
|
|
}
|
|
|
|
private:
|
|
Isolate* isolate_; // Current isolate pointer.
|
|
int argc_; // Number of arguments passed to the runtime call.
|
|
RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call.
|
|
RawObject** retval_; // Pointer to the return value area.
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // VM_NATIVE_ARGUMENTS_H_
|