Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Put everything in vm/main/ inside the namespace mozart.

  • Loading branch information...
commit d57f71c17d3022b0163fcd7ab6ff8bd75d948ddd 1 parent 33d4ae5
@sjrd sjrd authored
Showing with 223 additions and 10 deletions.
  1. +4 −0 vm/main/arrays.hh
  2. +4 −0 vm/main/atom-decl.hh
  3. +4 −0 vm/main/atom.hh
  4. +5 −0 vm/main/atomtable.hh
  5. +4 −0 vm/main/boolean-decl.hh
  6. +4 −0 vm/main/boolean.hh
  7. +4 −0 vm/main/callables-decl.hh
  8. +4 −0 vm/main/callables.hh
  9. +4 −0 vm/main/codearea-decl.hh
  10. +4 −0 vm/main/codearea.hh
  11. +12 −6 vm/main/core-forward-decl.hh
  12. +4 −0 vm/main/corebuiltins.cc
  13. +4 −0 vm/main/corebuiltins.hh
  14. +12 −0 vm/main/coreinterfaces.hh
  15. +4 −0 vm/main/emulate.cc
  16. +4 −0 vm/main/emulate.hh
  17. +4 −0 vm/main/exchelpers-decl.hh
  18. +4 −0 vm/main/exchelpers.hh
  19. +4 −0 vm/main/float-decl.hh
  20. +4 −0 vm/main/float.hh
  21. +4 −0 vm/main/gcollect-decl.hh
  22. +4 −0 vm/main/gcollect.cc
  23. +4 −0 vm/main/gcollect.hh
  24. +4 −0 vm/main/gctypes-decl.hh
  25. +4 −0 vm/main/gctypes.hh
  26. +4 −0 vm/main/memmanager.cc
  27. +4 −0 vm/main/memmanager.hh
  28. +4 −0 vm/main/memmanlist.hh
  29. +4 −0 vm/main/memword.hh
  30. +4 −0 vm/main/opcodes.hh
  31. +4 −0 vm/main/ozlimits.hh
  32. +4 −0 vm/main/records-decl.hh
  33. +4 −0 vm/main/records.hh
  34. +4 −0 vm/main/reference-decl.hh
  35. +4 −0 vm/main/reference.hh
  36. +4 −0 vm/main/runnable-decl.hh
  37. +4 −0 vm/main/runnable.hh
  38. +4 −0 vm/main/smallint-decl.hh
  39. +4 −0 vm/main/smallint.hh
  40. +4 −0 vm/main/storage.hh
  41. +4 −0 vm/main/store-decl.hh
  42. +4 −0 vm/main/store.hh
  43. +4 −0 vm/main/threadpool-decl.hh
  44. +4 −0 vm/main/threadpool.hh
  45. +4 −0 vm/main/type.hh
  46. +4 −0 vm/main/variables-decl.hh
  47. +4 −0 vm/main/variables.hh
  48. +6 −2 vm/main/vm-decl.hh
  49. +8 −2 vm/main/vm.hh
  50. +2 −0  vm/test/floattest.cc
  51. +2 −0  vm/test/smallinttest.cc
View
4 vm/main/arrays.hh
@@ -28,6 +28,8 @@
#include <cstdlib>
#include <cassert>
+namespace mozart {
+
/**
* A simple wrapper for an array and its size (only in debug mode)
* @param <T> Type of the elements in the array
@@ -89,4 +91,6 @@ public:
}
};
+}
+
#endif // __ARRAYS_H
View
4 vm/main/atom-decl.hh
@@ -30,6 +30,8 @@
#include <string>
#include <ostream>
+namespace mozart {
+
class Atom;
#ifndef MOZART_GENERATOR
@@ -71,4 +73,6 @@ private:
#include "Atom-implem-decl-after.hh"
#endif
+}
+
#endif // __ATOM_DECL_H
View
4 vm/main/atom.hh
@@ -29,6 +29,8 @@
#include "boolean.hh"
+namespace mozart {
+
#ifndef MOZART_GENERATOR
#include "Atom-implem.hh"
#endif
@@ -63,4 +65,6 @@ void Implementation<Atom>::printReprToStream(Self self, VM vm,
out << "<Atom>";
}
+}
+
#endif // __ATOM_H
View
5 vm/main/atomtable.hh
@@ -27,6 +27,8 @@
#include "core-forward-decl.hh"
+namespace mozart {
+
class Atom;
class AtomTable;
@@ -107,4 +109,7 @@ private:
AtomImpl* root;
size_t _count;
};
+
+}
+
#endif // __ATOMTABLE_H
View
4 vm/main/boolean-decl.hh
@@ -27,6 +27,8 @@
#include "mozartcore.hh"
+namespace mozart {
+
class Boolean;
typedef enum BOOL_OR_NOT_BOOL {
@@ -68,4 +70,6 @@ private:
#include "Boolean-implem-decl-after.hh"
#endif
+}
+
#endif // __BOOLEAN_DECL_H
View
4 vm/main/boolean.hh
@@ -27,6 +27,8 @@
#include "boolean-decl.hh"
+namespace mozart {
+
#ifndef MOZART_GENERATOR
#include "Boolean-implem.hh"
#endif
@@ -35,4 +37,6 @@ bool Implementation<Boolean>::build(VM vm, GC gc, Self from) {
return from.get().value();
}
+}
+
#endif // __BOOLEAN_H
View
4 vm/main/callables-decl.hh
@@ -29,6 +29,8 @@
#include "opcodes.hh"
+namespace mozart {
+
//////////////////////
// BuiltinProcedure //
//////////////////////
@@ -168,4 +170,6 @@ private:
#include "Abstraction-implem-decl-after.hh"
#endif
+}
+
#endif // __CALLABLES_DECL_H
View
4 vm/main/callables.hh
@@ -32,6 +32,8 @@
#include <iostream>
+namespace mozart {
+
/////////////////////////////
// Inline BuiltinProcedure //
/////////////////////////////
@@ -115,4 +117,6 @@ BuiltinResult Implementation<Abstraction>::getCallInfo(
return BuiltinResult::proceed();
}
+}
+
#endif // __CALLABLES_H
View
4 vm/main/codearea-decl.hh
@@ -30,6 +30,8 @@
#include <cstring>
+namespace mozart {
+
//////////////
// CodeArea //
//////////////
@@ -85,4 +87,6 @@ private:
#include "CodeArea-implem-decl-after.hh"
#endif
+}
+
#endif // __CODEAREA_DECL_H
View
4 vm/main/codearea.hh
@@ -27,6 +27,8 @@
#include "codearea-decl.hh"
+namespace mozart {
+
/////////////////////
// Inline CodeArea //
/////////////////////
@@ -67,4 +69,6 @@ Implementation<CodeArea>::getCodeAreaInfo(Self self, VM vm,
return BuiltinResult::proceed();
}
+}
+
#endif // __CODEAREA_H
View
18 vm/main/core-forward-decl.hh
@@ -34,6 +34,8 @@
#include <cstdlib>
#include <cstdint>
+namespace mozart {
+
typedef intptr_t nativeint;
class Type;
@@ -48,14 +50,18 @@ typedef VirtualMachine* VM;
class GarbageCollector;
typedef GarbageCollector* GC;
-inline
-void* operator new (size_t size, VM vm);
-
-inline
-void* operator new[] (size_t size, VM vm);
-
template <class T>
class Implementation {
};
+}
+
+// new operators must be declared outside of any namespace
+
+inline
+void* operator new (size_t size, mozart::VM vm);
+
+inline
+void* operator new[] (size_t size, mozart::VM vm);
+
#endif // __CORE_FORWARD_DECL_H
View
4 vm/main/corebuiltins.cc
@@ -30,6 +30,8 @@
#include "emulate.hh"
#include "exchelpers.hh"
+namespace mozart {
+
namespace builtins {
BuiltinResult equals(VM vm, UnstableNode* args[]) {
@@ -147,3 +149,5 @@ void printReprToStream(VM vm, RichNode arg,
}
}
+
+}
View
4 vm/main/corebuiltins.hh
@@ -27,6 +27,8 @@
#include "mozartcore.hh"
+namespace mozart {
+
namespace builtins {
BuiltinResult equals(VM vm, UnstableNode* args[]);
@@ -52,4 +54,6 @@ void printReprToStream(VM vm, RichNode node,
}
+}
+
#endif // __COREBUILTINS_H
View
12 vm/main/coreinterfaces.hh
@@ -40,6 +40,8 @@
#include <iostream>
+namespace mozart {
+
class DataflowVariable;
template<>
struct Interface<DataflowVariable>: ImplementedBy<Unbound, Variable>, NoAutoWait {
@@ -218,8 +220,12 @@ struct Interface<ArrayInitializer>:
}
};
+} // namespace mozart
+
#ifndef MOZART_GENERATOR
+namespace mozart {
+
#include "DataflowVariable-interf.hh"
#include "Equatable-interf.hh"
#include "BuiltinCallable-interf.hh"
@@ -232,6 +238,8 @@ struct Interface<ArrayInitializer>:
#include "RecordLike-interf.hh"
#include "ArrayInitializer-interf.hh"
+} // namespace mozart
+
#include "variables.hh"
#include "boolean.hh"
#include "smallint.hh"
@@ -243,6 +251,8 @@ struct Interface<ArrayInitializer>:
#include "exchelpers.hh"
+namespace mozart {
+
/////////////
// Inlines //
/////////////
@@ -273,6 +283,8 @@ BuiltinResult Interface<DataflowVariable>::bind(RichNode self, VM vm,
}
}
+} // namespace mozart
+
#endif // MOZART_GENERATOR
#endif // __COREINTERFACES_H
View
4 vm/main/emulate.cc
@@ -31,6 +31,8 @@
#include "corebuiltins.hh"
#include "variables.hh"
+namespace mozart {
+
const ProgramCounter NullPC = nullptr;
////////////////
@@ -717,4 +719,6 @@ Runnable* Thread::gCollect(GC gc) {
return new (gc->vm) Thread(gc, *this);
}
+}
+
#undef advancePC
View
4 vm/main/emulate.hh
@@ -37,6 +37,8 @@
#include "runnable.hh"
#include "smallint.hh"
+namespace mozart {
+
/**
* Entry of a thread stack
*/
@@ -189,4 +191,6 @@ private:
VMAllocatedList<StackEntry> stack;
};
+}
+
#endif // __EMULATE_H
View
4 vm/main/exchelpers-decl.hh
@@ -27,10 +27,14 @@
#include "mozartcore.hh"
+namespace mozart {
+
inline
BuiltinResult raiseAtom(VM vm, const char16_t* atom);
inline
BuiltinResult raiseTypeError(VM vm, const char16_t* expected, RichNode actual);
+}
+
#endif // __EXCHELPERS_DECL_H
View
4 vm/main/exchelpers.hh
@@ -29,6 +29,8 @@
#include "coreinterfaces.hh"
+namespace mozart {
+
BuiltinResult raiseAtom(VM vm, const char16_t* atom) {
UnstableNode exception;
exception.make<Atom>(vm, atom);
@@ -54,4 +56,6 @@ BuiltinResult raiseTypeError(VM vm, const char16_t* expected, RichNode actual) {
return BuiltinResult::raise(vm, exception);
}
+}
+
#endif // __EXCHELPERS_H
View
4 vm/main/float-decl.hh
@@ -27,6 +27,8 @@
#include "mozartcore.hh"
+namespace mozart {
+
class Float;
#ifndef MOZART_GENERATOR
@@ -106,4 +108,6 @@ private:
#include "Float-implem-decl-after.hh"
#endif
+}
+
#endif // __FLOAT_DECL_H
View
4 vm/main/float.hh
@@ -32,6 +32,8 @@
#include <iostream>
+namespace mozart {
+
//////////////////
// Inline Float //
//////////////////
@@ -165,4 +167,6 @@ BuiltinResult Implementation<Float>::mod(Self self, VM vm,
return raiseTypeError(vm, u"Integer", self);
}
+}
+
#endif // __FLOAT_H
View
4 vm/main/gcollect-decl.hh
@@ -32,6 +32,8 @@
#include "runnable-decl.hh"
+namespace mozart {
+
// Set this to true to print debug info about the GC
#ifdef OZ_DEBUG_GC
const bool OzDebugGC = true;
@@ -89,4 +91,6 @@ private:
MemManagedList<StableNode**> stableRefsToGC;
};
+}
+
#endif // __GCOLLECT_DECL_H
View
4 vm/main/gcollect.cc
@@ -26,6 +26,8 @@
#include <iostream>
+namespace mozart {
+
//////////////////////
// GarbageCollector //
//////////////////////
@@ -124,3 +126,5 @@ void GarbageCollector::gcOneStableRef(StableNode*& ref) {
from.remake<GCedToStable>(vm, ref);
}
}
+
+}
View
4 vm/main/gcollect.hh
@@ -29,6 +29,8 @@
#include "vm-decl.hh"
+namespace mozart {
+
void ThreadQueue::gCollect(GC gc) {
for (auto iterator = c.begin(); iterator != c.end(); iterator++) {
Runnable*& thread = *iterator;
@@ -66,4 +68,6 @@ void GarbageCollector::gcStableRef(StableNode* from, StableNode*& to) {
stableRefsToGC.push_front(secondMemManager, &to);
}
+}
+
#endif // __GCOLLECT_H
View
4 vm/main/gctypes-decl.hh
@@ -28,6 +28,8 @@
#include "vm-decl.hh"
#include "type.hh"
+namespace mozart {
+
//////////////////
// GCedToStable //
//////////////////
@@ -110,4 +112,6 @@ private:
#include "GCedToUnstable-implem-decl-after.hh"
#endif
+}
+
#endif // __GCTYPES_DECL_H
View
4 vm/main/gctypes.hh
@@ -31,6 +31,8 @@
#ifndef MOZART_GENERATOR
+namespace mozart {
+
//////////////////
// GCedToStable //
//////////////////
@@ -91,6 +93,8 @@ void GCedToUnstableBase::gCollect(GC gc, RichNode from, UnstableNode& to) const
to.copy(gc->vm, *dest);
}
+}
+
#endif // MOZART_GENERATOR
#endif // __GCTYPES_H
View
4 vm/main/memmanager.cc
@@ -27,6 +27,8 @@
#include <new>
#include <iostream>
+namespace mozart {
+
///////////////////
// MemoryManager //
///////////////////
@@ -41,3 +43,5 @@ void* MemoryManager::getMoreMemory(size_t size) {
std::bad_alloc ba;
throw ba;
}
+
+}
View
4 vm/main/memmanager.hh
@@ -27,6 +27,8 @@
#include <algorithm>
+namespace mozart {
+
const size_t MegaBytes = 1024*1024;
const size_t MAX_MEMORY = 512 * MegaBytes;
@@ -141,4 +143,6 @@ private:
void* freeListBuckets[MaxBuckets];
};
+}
+
#endif // __MEMMANAGER_H
View
4 vm/main/memmanlist.hh
@@ -29,6 +29,8 @@
#include <cassert>
+namespace mozart {
+
////////////////////
// MemManagedList //
////////////////////
@@ -197,4 +199,6 @@ private:
ListNode* last;
};
+}
+
#endif // __MEMMANLIST_H
View
4 vm/main/memword.hh
@@ -41,6 +41,8 @@
#include "core-forward-decl.hh"
+namespace mozart {
+
// MWTest is a metafunction that returns T if i!=0 and a type guaranteed to be
// smaller or equal to char* if i==0
template<class T, int i>
@@ -125,4 +127,6 @@ typedef MWUnion<nativeint, bool, double> MemWord;
static_assert(sizeof(MemWord) == sizeof(char *),
"MemWord has not the size of a word");
+}
+
#endif // __MEMWORD_H
View
4 vm/main/opcodes.hh
@@ -25,6 +25,8 @@
#ifndef __OPCODES_H
#define __OPCODES_H
+namespace mozart {
+
typedef short unsigned int uint16_t;
typedef uint16_t ByteCode;
@@ -88,4 +90,6 @@ const OpCode OpInlineSubtract = 0x52;
const OpCode OpInlinePlus1 = 0x53;
const OpCode OpInlineMinus1 = 0x54;
+}
+
#endif // __OPCODES_H
View
4 vm/main/ozlimits.hh
@@ -25,6 +25,10 @@
#ifndef __OZLIMITS_H
#define __OZLIMITS_H
+namespace mozart {
+
constexpr int InitXRegisters = 64;
+}
+
#endif // __OZLIMITS_H
View
4 vm/main/records-decl.hh
@@ -27,6 +27,8 @@
#include "mozartcore.hh"
+namespace mozart {
+
///////////
// Tuple //
///////////
@@ -88,4 +90,6 @@ private:
#include "Tuple-implem-decl-after.hh"
#endif
+}
+
#endif // __RECORDS_DECL_H
View
4 vm/main/records.hh
@@ -32,6 +32,8 @@
#include "boolean.hh"
#include "corebuiltins.hh"
+namespace mozart {
+
//////////////////
// Inline Tuple //
//////////////////
@@ -124,4 +126,6 @@ void Implementation<Tuple>::printReprToStream(Self self, VM vm,
out << ")";
}
+}
+
#endif // __RECORDS_H
View
4 vm/main/reference-decl.hh
@@ -28,6 +28,8 @@
#include "vm-decl.hh"
#include "type.hh"
+namespace mozart {
+
///////////////
// Reference //
///////////////
@@ -61,4 +63,6 @@ private:
#include "Reference-implem-decl-after.hh"
#endif
+}
+
#endif // __REFERENCE_DECL_H
View
4 vm/main/reference.hh
@@ -27,6 +27,8 @@
#include "reference-decl.hh"
+namespace mozart {
+
///////////////
// Reference //
///////////////
@@ -35,4 +37,6 @@
#include "Reference-implem.hh"
#endif
+}
+
#endif // __REFERENCE_H
View
4 vm/main/runnable-decl.hh
@@ -27,6 +27,8 @@
#include "core-forward-decl.hh"
+namespace mozart {
+
// This enum is often used for indexing in arrays
// tpCount reflects the number of valid ThreadPriority's
// And you probably don't want to add or remove existing ThreadPriority's
@@ -146,4 +148,6 @@ private:
Runnable* last;
};
+}
+
#endif // __RUNNABLE_DECL_H
View
4 vm/main/runnable.hh
@@ -28,6 +28,8 @@
#include "runnable-decl.hh"
#include "vm-decl.hh"
+namespace mozart {
+
Runnable::Runnable(VM vm, ThreadPriority priority) :
vm(vm), _priority(priority), _runnable(true), _terminated(false) {
@@ -51,4 +53,6 @@ void Runnable::terminate() {
vm->aliveThreads.remove(this);
}
+}
+
#endif // __RUNNABLE_H
View
4 vm/main/smallint-decl.hh
@@ -27,6 +27,8 @@
#include "mozartcore.hh"
+namespace mozart {
+
class SmallInt;
#ifndef MOZART_GENERATOR
@@ -113,4 +115,6 @@ private:
#include "SmallInt-implem-decl-after.hh"
#endif
+}
+
#endif // __SMALLINT_DECL_H
View
4 vm/main/smallint.hh
@@ -33,6 +33,8 @@
#include <limits>
#include <iostream>
+namespace mozart {
+
/////////////////////
// Inline SmallInt //
/////////////////////
@@ -244,4 +246,6 @@ BuiltinResult Implementation<SmallInt>::modValue(Self self, VM vm,
return BuiltinResult::proceed();
}
+}
+
#endif // __SMALLINT_H
View
4 vm/main/storage.hh
@@ -30,6 +30,8 @@
#include "memword.hh"
#include "arrays.hh"
+namespace mozart {
+
template<class I, class E>
class ImplWithArray {
I* p;
@@ -130,4 +132,6 @@ public:
}
};
+}
+
#endif // __STORAGE_H
View
4 vm/main/store-decl.hh
@@ -31,6 +31,8 @@
#include <string>
+namespace mozart {
+
/**
* A value node in the store.
* The store is entirely made of nodes. A node is basically a typed value.
@@ -420,4 +422,6 @@ protected:
Self _self;
};
+}
+
#endif // __STORE_DECL_H
View
4 vm/main/store.hh
@@ -33,6 +33,8 @@
#ifndef MOZART_GENERATOR
+namespace mozart {
+
/////////////////////////
// Node implementation //
/////////////////////////
@@ -201,6 +203,8 @@ BuiltinResult BuiltinResult::raise(VM vm, RichNode node) {
return BuiltinResult(node.getStableRef(vm), brRaise);
}
+}
+
#endif // MOZART_GENERATOR
#endif // __STORE_H
View
4 vm/main/threadpool-decl.hh
@@ -30,6 +30,8 @@
#include "core-forward-decl.hh"
#include "runnable-decl.hh"
+namespace mozart {
+
/////////////////
// ThreadQueue //
/////////////////
@@ -105,4 +107,6 @@ private:
int remainings[tpCount];
};
+}
+
#endif // __THREADPOOL_DECL_H
View
4 vm/main/threadpool.hh
@@ -27,6 +27,8 @@
#include "threadpool-decl.hh"
+namespace mozart {
+
////////////////
// ThreadPool //
////////////////
@@ -66,4 +68,6 @@ Runnable* ThreadPool::popNext(ThreadPriority priority) {
return result;
}
+}
+
#endif // __THREADPOOL_H
View
4 vm/main/type.hh
@@ -31,6 +31,8 @@
#include "store-decl.hh"
+namespace mozart {
+
class Type {
public:
Type(std::string name, bool copiable = false, bool transient = false) :
@@ -80,4 +82,6 @@ template<class>
struct BasedOn{};
struct NoAutoGCollect{};
+}
+
#endif // __TYPE_H
View
4 vm/main/variables-decl.hh
@@ -27,6 +27,8 @@
#include "mozartcore.hh"
+namespace mozart {
+
//////////////
// Variable //
//////////////
@@ -101,4 +103,6 @@ public:
#include "Unbound-implem-decl-after.hh"
#endif
+}
+
#endif // __VARIABLES_DECL_H
View
4 vm/main/variables.hh
@@ -29,6 +29,8 @@
#include "coreinterfaces.hh"
+namespace mozart {
+
//////////////////////
// Inline Variable ///
//////////////////////
@@ -110,4 +112,6 @@ BuiltinResult Implementation<Unbound>::bind(Self self, VM vm, RichNode src) {
return BuiltinResult::proceed();
}
+}
+
#endif // __VARIABLES_H
View
8 vm/main/vm-decl.hh
@@ -38,6 +38,8 @@
#include "atomtable.hh"
+namespace mozart {
+
////////////////////
// VirtualMachine //
////////////////////
@@ -93,8 +95,8 @@ private:
VirtualMachine(const VirtualMachine& src) : gc(this) {}
- friend void* operator new (size_t size, VM vm);
- friend void* operator new[] (size_t size, VM vm);
+ friend void* ::operator new (size_t size, mozart::VM vm);
+ friend void* ::operator new[] (size_t size, mozart::VM vm);
void* getMemory(size_t size) {
return memoryManager.getMemory(size);
@@ -159,4 +161,6 @@ public:
}
};
+}
+
#endif // __VM_DECL_H
View
10 vm/main/vm.hh
@@ -27,6 +27,8 @@
#include "vm-decl.hh"
+namespace mozart {
+
////////////////////
// VirtualMachine //
////////////////////
@@ -66,11 +68,15 @@ void VirtualMachine::scheduleThread(Runnable* thread) {
threadPool.schedule(thread);
}
-void* operator new (size_t size, VM vm) {
+}
+
+// new operators must be declared outside of any namespace
+
+void* operator new (size_t size, mozart::VM vm) {
return vm->getMemory(size);
}
-void* operator new[] (size_t size, VM vm) {
+void* operator new[] (size_t size, mozart::VM vm) {
return vm->getMemory(size);
}
View
2  vm/test/floattest.cc
@@ -4,6 +4,8 @@
#include <gtest/gtest.h>
+using namespace mozart;
+
class FloatTest : public ::testing::Test {
protected:
FloatTest() : virtualMachine(nullptr, nullptr), vm(&virtualMachine) {}
View
2  vm/test/smallinttest.cc
@@ -4,6 +4,8 @@
#include <gtest/gtest.h>
+using namespace mozart;
+
class SmallIntTest : public ::testing::Test {
protected:
SmallIntTest() : virtualMachine(nullptr, nullptr), vm(&virtualMachine) {}
Please sign in to comment.
Something went wrong with that request. Please try again.