Permalink
Browse files

Define methods as const where appropriate

This makes them explicit about not modifying the current receiving
object. Also removes a few unused pieces of code that were still
lingering in here.
  • Loading branch information...
1 parent a528c19 commit 573964b7e98d44b7d87bd8ecd1e2ec0321ca2947 @dbussink dbussink committed May 26, 2013
Showing with 295 additions and 397 deletions.
  1. +11 −11 vm/agent.hpp
  2. +3 −3 vm/agent_components.cpp
  3. +7 −7 vm/arguments.hpp
  4. +1 −1 vm/builtin/bytearray.hpp
  5. +5 −5 vm/builtin/call_site.hpp
  6. +0 −19 vm/builtin/channel.cpp
  7. +0 −4 vm/builtin/channel.hpp
  8. +6 −6 vm/builtin/class.hpp
  9. +0 −5 vm/builtin/compiledcode.cpp
  10. +0 −2 vm/builtin/compiledcode.hpp
  11. +2 −2 vm/builtin/constant_cache.hpp
  12. +1 −1 vm/builtin/constantscope.hpp
  13. +1 −1 vm/builtin/data.hpp
  14. +2 −2 vm/builtin/encoding.cpp
  15. +4 −4 vm/builtin/encoding.hpp
  16. +2 −2 vm/builtin/executable.hpp
  17. +8 −8 vm/builtin/fiber.hpp
  18. +4 −4 vm/builtin/heap_dump.cpp
  19. +1 −4 vm/builtin/methodtable.cpp
  20. +11 −11 vm/builtin/nativemethod.hpp
  21. +1 −2 vm/builtin/object.hpp
  22. +11 −11 vm/builtin/poly_inline_cache.hpp
  23. +2 −2 vm/builtin/string.hpp
  24. +2 −2 vm/builtin/thread.hpp
  25. +6 −6 vm/builtin/variable_scope.hpp
  26. +2 −2 vm/builtin/weakref.hpp
  27. +6 −2 vm/bytecode_verification.hpp
  28. +23 −23 vm/call_frame.hpp
  29. +2 −2 vm/environment.hpp
  30. +1 −1 vm/exception_point.hpp
  31. +11 −11 vm/fiber_data.hpp
  32. +5 −5 vm/fiber_stack.hpp
  33. +4 −4 vm/gc/code_manager.hpp
  34. +2 −2 vm/gc/code_resource.hpp
  35. +1 −1 vm/gc/finalize.hpp
  36. +1 −1 vm/gc/gc.hpp
  37. +4 −4 vm/gc/managed.hpp
  38. +3 −3 vm/gc/root.hpp
  39. +2 −2 vm/gc/slab.hpp
  40. +2 −2 vm/instruments/tooling.hpp
  41. +7 −7 vm/linkedlist.hpp
  42. +0 −5 vm/llvm/jit_compiler.cpp
  43. +0 −1 vm/llvm/jit_compiler.hpp
  44. +7 −6 vm/llvm/state.cpp
  45. +2 −2 vm/lock.hpp
  46. +1 −5 vm/machine_code.cpp
  47. +23 −24 vm/machine_code.hpp
  48. +1 −1 vm/marshal.hpp
  49. +0 −12 vm/objectmemory.cpp
  50. +5 −6 vm/objectmemory.hpp
  51. +1 −14 vm/oop.cpp
  52. +1 −6 vm/oop.hpp
  53. +4 −4 vm/primitives.hpp
  54. +2 −2 vm/shared_state.cpp
  55. +15 −15 vm/shared_state.hpp
  56. +7 −7 vm/stack_variables.hpp
  57. +0 −8 vm/state.cpp
  58. +3 −4 vm/state.hpp
  59. +2 −2 vm/symboltable.cpp
  60. +2 −2 vm/symboltable.hpp
  61. +3 −3 vm/unwind_info.hpp
  62. +15 −15 vm/util/bert.hpp
  63. +1 −3 vm/util/configuration.hpp
  64. +1 −1 vm/util/refcount.hpp
  65. +10 −25 vm/util/thread.hpp
  66. +0 −4 vm/vm.cpp
  67. +17 −18 vm/vm.hpp
  68. +4 −4 vm/vm_thread_state.hpp
  69. +1 −1 vm/world_state.hpp
View
@@ -40,7 +40,7 @@ namespace rubinius {
state = eRunning;
}
- bool needs_auth_p() {
+ bool needs_auth_p() const {
return state == eWaitingAuth;
}
@@ -84,31 +84,31 @@ namespace rubinius {
verbose_ = true;
}
- int port() {
+ int port() const {
return port_;
}
- fd_set fds() {
+ fd_set fds() const {
return fds_;
}
- int max_fd() {
+ int max_fd() const {
return max_fd_;
}
- int server_fd() {
+ int server_fd() const {
return server_fd_;
}
- bool local_only() {
+ bool local_only() const {
return local_only_;
}
- bool use_password() {
+ bool use_password() const {
return use_password_;
}
- bool verbose() {
+ bool verbose() const {
return verbose_;
}
@@ -129,15 +129,15 @@ namespace rubinius {
FD_CLR((int_fd_t)fd, &fds_);
}
- int loopback_socket() {
+ int loopback_socket() const {
return loopback_[1];
}
- int read_control() {
+ int read_control() const {
return control_[0];
}
- int write_control() {
+ int write_control() const {
return control_[1];
}
View
@@ -37,15 +37,15 @@ namespace agent {
free(const_cast<char*>(name_));
}
- Kind kind() {
+ Kind kind() const {
return kind_;
}
- bool tree_p() {
+ bool tree_p() const {
return kind_ == eTree;
}
- const char* name() {
+ const char* name() const {
return name_;
}
View
@@ -64,45 +64,45 @@ namespace rubinius {
use_array(ary);
}
- Symbol* name() {
+ Symbol* name() const {
return name_;
}
void set_name(Symbol* n) {
name_ = n;
}
- Object* recv() {
+ Object* recv() const {
return recv_;
}
void set_recv(Object* val) {
recv_ = val;
}
- Object* block() {
+ Object* block() const {
return block_;
}
void set_block(Object* val) {
block_ = val;
}
- Object* get_argument(uint32_t which) {
+ Object* get_argument(uint32_t which) const {
return arguments_[which];
}
- Object** arguments() {
+ Object** arguments() const {
return arguments_;
}
- Tuple* argument_container() {
+ Tuple* argument_container() const {
return argument_container_;
}
void update_argument_container(Tuple* obj);
- uint32_t total() {
+ uint32_t total() const {
return total_;
}
View
@@ -34,7 +34,7 @@ namespace rubinius {
Fixnum* size(STATE);
// Return the number of bytes this ByteArray contains
- native_int size() {
+ native_int size() const {
return full_size_ - bytes_offset;
}
View
@@ -42,7 +42,7 @@ namespace rubinius {
static void init(STATE);
- int ip() {
+ int ip() const {
return ip_;
}
@@ -68,7 +68,7 @@ namespace rubinius {
static void empty_cache_updater(STATE, CallSite* call_site, Class* klass, Dispatch& dispatch);
- bool regular_call() {
+ bool regular_call() const {
return type_id() == MonoInlineCacheType || type_id() == PolyInlineCacheType;
}
@@ -94,9 +94,9 @@ namespace rubinius {
fallback_ = empty_cache_custom;
}
- void set_executor(CacheExecutor executor) {
- executor_ = executor;
- fallback_ = executor;
+ void set_executor(CacheExecutor exec) {
+ executor_ = exec;
+ fallback_ = exec;
}
void update_call_site(STATE, CallSite* other) {
View
@@ -34,25 +34,6 @@ namespace rubinius {
return chan;
}
- Channel* Channel::create_primed(STATE) {
- Channel* chan = state->vm()->new_object_mature<Channel>(G(channel));
- chan->waiters_ = 0;
- chan->semaphore_count_ = 1;
-
- // Using placement new to call the constructor of condition_
- new(&chan->condition_) utilities::thread::Condition();
- new(&chan->mutex_) utilities::thread::Mutex();
-
- chan->value(state, List::create(state));
-
- return chan;
- }
-
- /** @todo Remove the event too? Should not affect code, but no need for it either. --rue */
- void Channel::cancel_waiter(STATE, const Thread* waiter) {
- // waiting_->remove(state, waiter);
- }
-
Object* Channel::send(STATE, GCToken gct, Object* val, CallFrame* calling_environment) {
Channel* self = this;
View
@@ -35,10 +35,6 @@ namespace rubinius {
// Rubinius.primitive :channel_new
static Channel* create(STATE);
- static Channel* create_primed(STATE);
-
- /** Remove Thread from waiting list, if it is there. */
- void cancel_waiter(STATE, const Thread* waiter);
// Rubinius.primitive :channel_send
Object* send(STATE, GCToken gct, Object* val, CallFrame* calling_environment);
View
@@ -38,27 +38,27 @@ namespace rubinius {
attr_accessor(packed_ivar_info, LookupTable);
attr_accessor(instance_type, Fixnum);
- TypeInfo* type_info() {
+ TypeInfo* type_info() const {
return type_info_;
}
void set_type_info(TypeInfo* ti) {
type_info_ = ti;
}
- ClassData data() {
+ ClassData data() const {
return data_;
}
- uint64_t data_raw() {
+ uint64_t data_raw() const {
return data_.raw;
}
- uint32_t class_id() {
+ uint32_t class_id() const {
return data_.f.class_id;
}
- uint32_t serial_id() {
+ uint32_t serial_id() const {
return data_.f.serial_id;
}
@@ -70,7 +70,7 @@ namespace rubinius {
data_.f.class_id = id;
}
- uint32_t packed_size() {
+ uint32_t packed_size() const {
return packed_size_;
}
@@ -337,11 +337,6 @@ namespace rubinius {
return false;
}
- void CompiledCode::set_interpreter(executor interp) {
- set_executor(interp);
- machine_code_->fallback = interp;
- }
-
Object* CompiledCode::set_breakpoint(STATE, GCToken gct, Fixnum* ip, Object* bp, CallFrame* calling_environment) {
CompiledCode* self = this;
OnStack<3> os(state, self, ip, bp);
@@ -130,8 +130,6 @@ namespace rubinius {
bool kernel_method(STATE);
- void set_interpreter(executor interp);
-
class Info : public Executable::Info {
public:
BASIC_TYPEINFO(Executable::Info)
@@ -29,8 +29,8 @@ namespace rubinius {
attr_accessor(scope, ConstantScope);
attr_accessor(executable, Executable);
- int ip() { return ip_; }
- int serial() { return serial_; }
+ int ip() const { return ip_; }
+ int serial() const { return serial_; }
// Rubinius.primitive :constant_cache_ip
Integer* ip_prim(STATE);
@@ -55,7 +55,7 @@ namespace rubinius {
// Rubinius.primitive :constant_scope_cvar_get_or_set
Object* cvar_get_or_set(STATE, Symbol* name, Object* value);
- bool top_level_p(STATE) {
+ bool top_level_p(STATE) const {
return parent_->nil_p();
}
View
@@ -37,7 +37,7 @@ namespace rubinius {
static void finalize(STATE, Data* data);
- bool freed_p() {
+ bool freed_p() const {
return freed_;
}
View
@@ -279,7 +279,7 @@ namespace rubinius {
if(str_b && str_b->byte_size() == 0) return enc_a;
if(str_a && str_a->byte_size() == 0) {
if(CBOOL(enc_a->ascii_compatible_p(state))
- && CBOOL(str_b->ascii_only_p(state))) {
+ && str_b && CBOOL(str_b->ascii_only_p(state))) {
return enc_a;
} else {
return enc_b;
@@ -310,7 +310,7 @@ namespace rubinius {
if(ascii_b) return enc_a;
if(ascii_a) return enc_b;
} else if(!str_b) {
- if(CBOOL(str_a->ascii_only_p(state))) return enc_b;
+ if(str_a && CBOOL(str_a->ascii_only_p(state))) return enc_b;
}
return nil<Encoding>();
View
@@ -93,7 +93,7 @@ namespace rubinius {
static int mbclen(const uint8_t* start, const uint8_t* end, OnigEncodingType* enc);
static int precise_mbclen(const uint8_t* start, const uint8_t* end, OnigEncodingType* enc);
- OnigEncodingType* get_encoding() {
+ OnigEncodingType* get_encoding() const {
return encoding_;
}
@@ -103,7 +103,7 @@ namespace rubinius {
void make_managed(STATE, const char* name, OnigEncodingType* enc);
- bool get_managed() {
+ bool get_managed() const {
return managed_;
}
@@ -163,7 +163,7 @@ namespace rubinius {
converter_ = c;
}
- rb_econv_t* get_converter() {
+ rb_econv_t* get_converter() const {
return converter_;
}
@@ -214,7 +214,7 @@ namespace rubinius {
static void declare(STATE, const char* from, const char* to, const char* lib);
static void define(STATE, OnigTranscodingType* tr);
- OnigTranscodingType* get_transcoder() {
+ OnigTranscodingType* get_transcoder() const {
return transcoder_;
}
@@ -54,11 +54,11 @@ namespace rubinius {
execute = exc;
}
- int prim_index() {
+ int prim_index() const {
return prim_index_;
}
- bool custom_call_site_p() {
+ bool custom_call_site_p() const {
return custom_call_site_;
}
Oops, something went wrong.

0 comments on commit 573964b

Please sign in to comment.