Skip to content

Commit

Permalink
adds primitive blocks, WIP not finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytregunna committed Jan 23, 2012
1 parent 5ccc595 commit a37d8e7
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 2.6)
project(Acute)

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules/")

add_subdirectory(wee)
14 changes: 14 additions & 0 deletions wee/CMakeLists.txt
@@ -0,0 +1,14 @@
set(CMAKE_CXX_FLAGS "-g -std=c++0x -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS")
set(SRCS
"symtab.cpp"
"gc.cpp"
"object.cpp"
"message.cpp"
"array.cpp"
"integer.cpp"
"string.cpp"
"nil.cpp"
"object_space.cpp"
)

add_library(wee SHARED ${SRCS})
44 changes: 44 additions & 0 deletions wee/block.cpp
@@ -0,0 +1,44 @@
/*
* Acute Programming Language
* Copyright (c) 2011, Jeremy Tregunna, All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

#include <string>
#include "block.hpp"
#include "object.hpp"
#include "message.hpp"

namespace Acute
{
Block::Block(Message* body, ArgNames argNames, Object* ctx) : message(body), argumentNames(argNames), scope(ctx)
{
locals = new Object();
}

void Block::walk()
{
generic_object_walk();
collector->shade(locals);
if(scope)
collector->shade(scope);
collector->shade(message);
}
}
53 changes: 53 additions & 0 deletions wee/block.hpp
@@ -0,0 +1,53 @@
/*
* Acute Programming Language
* Copyright (c) 2011, Jeremy Tregunna, All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

#ifndef __ACUTE__BLOCK_HPP__
#define __ACUTE__BLOCK_HPP__

#include <vector>
#include <string>
#include "object.hpp"
#include "message.hpp"

namespace Acute
{
typedef std::vector<std::string> ArgNames;

class Block : public Object
{
private:
Message* message;
Object* scope;
ArgNames argumentNames;
Object* locals;

public:
Block(Message*, ArgNames, Object*);
~Block();

virtual const std::string object_name();
virtual void walk();
};
}

#endif /* !__ACUTE__BLOCK_HPP__ */
2 changes: 2 additions & 0 deletions wee/gc.cpp
Expand Up @@ -30,6 +30,8 @@

namespace Acute
{
GarbageCollector* collector = nullptr;

GarbageCollector::GarbageCollector()
{
blacks = new GCMarker(kGCColourBlack);
Expand Down

0 comments on commit a37d8e7

Please sign in to comment.