]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Created seperate debug build with memory leak detection. Removed cork dependency...
authorMike D. Lowis <mike@mdlowis.com>
Thu, 8 Mar 2012 20:31:46 +0000 (15:31 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Thu, 8 Mar 2012 20:31:46 +0000 (15:31 -0500)
example.dl
rakefile.rb
source/common.h [new file with mode: 0644]
source/dllexer/dllexer.cpp
source/dlparser/dlparser.cpp
source/dlparser/macro/pattern.cpp
source/dlparser/macro/pattern.h
source/main.cpp

index e684e126aa60d9857f289f9d22ee3bde43a5dea4..4254f91b98f21e70ac91fed54c007f0a2f6310eb 100644 (file)
@@ -3,64 +3,64 @@
 #------------------------------------------------------------------------------
 
 # VectorLiteral
-#foo = []
-#foo = [1]
-#foo = [1,2,3]
-#foo = foo[1]
-#foo = [1,2,3,4,5][2]
+foo = []
+foo = [1]
+foo = [1,2,3]
+foo = foo[1]
+foo = [1,2,3,4,5][2]
 
 # ListLiteral
-#foo = ()
-#foo = (1,2,3)
-#foo = foo[1]
-#foo = (1,2,3,4,5)[2]
+foo = ()
+foo = (1,2,3)
+foo = foo[1]
+foo = (1,2,3,4,5)[2]
 
 # FuncLiteral
 foo = { 1 + 1 }
-#foo = {|a| a + 1}
-#foo = {|a,b| a + b }
-#foo = foo(1,2)
-#foo = ({|a,b| a + b })(1,2)
+foo = {|a| a + 1}
+foo = {|a,b| a + b }
+foo = foo(1,2)
+foo = ({|a,b| a + b })(1,2)
 
 # ID
-#foo = bar
-#foo.bar = bar
+foo = bar
+foo.bar = bar
 
 # NUM
-#foo = 1
-#foo = 1.0
+foo = 1
+foo = 1.0
 
 # CHAR
-#foo = 'a'
+foo = 'a'
 
 # STRING
-#foo = "some string"
-#foo = "12345"[2]
+foo = "some string"
+foo = "12345"[2]
 
 # SYMBOL
-#foo = $some_symbol
+foo = $some_symbol
 
 # MAP
-#foo = {
-#    $foo : 1 + 1,
-#    $bar : 2 + 2,
-#    $stuff : 3 + 3
-#}
+foo = {
+    $foo : 1 + 1,
+    $bar : 2 + 2,
+    $stuff : 3 + 3
+}
 
 # Macro
-#% if [
-#    (Expression Block Block) : exec_if($1, $2, $3),
-#    (Expression Block) : exec_if($1, $2)
-#]
+% if [
+    (Expression Block Block) : exec_if($1, $2, $3),
+    (Expression Block) : exec_if($1, $2)
+]
 
-#if (1==1)
-#{
-#    1 + 1
-#}{
-#
-#}
-#
-#if (1 == 1)
-#{
-#
-#}
+if (1==1)
+{
+    1 + 1
+}{
+
+}
+
+if (1 == 1)
+{
+
+}
index 98622c7b2207db2290c65aa41e05a6c92b548e14..54311e77ec8513aa9e370e554756ddd0106d1f14 100644 (file)
@@ -15,15 +15,32 @@ CLOBBER.include('./deps/parse-utils/build/shared')
 #------------------------------------------------------------------------------
 # Configuration Objects
 #------------------------------------------------------------------------------
-# Configuration for the binary artifact
+# Configuration for the release binary artifact
 DLangParser = Binary.new({
     :name => 'dlang',
-    :output_dir => 'build/parser',
+    :output_dir => 'build/release',
+    :compiler_options => [ '-c', '-Wall', '-Werror', '-o' ],
+    :static_libs => [
+        './deps/parse-utils/build/static/bin/libparse-utils.a',
+    ],
+    :source_files => [ 'source/**/*.c*' ],
+    :include_dirs => [
+        'source/**/',
+        'deps/parse-utils/source/**/'
+    ],
+})
+DLangParser.setup_default_rake_tasks()
+
+# Configuration for the release binary artifact
+DLangDebug = Binary.new({
+    :name => 'dlang',
+    :output_dir => 'build/debug',
     :compiler_options => [ '-c', '-Wall', '-Werror', '-o' ],
     :static_libs => [
         './deps/cork/build/static/bin/libcork.a',
         './deps/parse-utils/build/static/bin/libparse-utils.a',
     ],
+    :preprocessor_defines => [ 'DEBUG' ],
     :source_files => [ 'source/**/*.c*' ],
     :include_dirs => [
         'source/**/',
@@ -31,7 +48,7 @@ DLangParser = Binary.new({
         'deps/parse-utils/source/**/'
     ],
 })
-DLangParser.setup_default_rake_tasks()
+DLangDebug.setup_default_rake_tasks()
 
 # Configuration for the unit tests
 UnitTest = Tests.new({
@@ -39,8 +56,12 @@ UnitTest = Tests.new({
 })
 UnitTest.setup_default_rake_tasks()
 
+#------------------------------------------------------------------------------
+# Main Tasks
+#------------------------------------------------------------------------------
 desc 'Build and link all artifacts'
-task :release => [ :cork, :parse_utils, DLangParser.name() ]
+task :release => [ :parse_utils, DLangParser.name() ]
+task :debug => [ :cork, :parse_utils, DLangDebug.name() ]
 
 desc 'Build the cork memory leak detector'
 task :cork do
diff --git a/source/common.h b/source/common.h
new file mode 100644 (file)
index 0000000..10f8c76
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef COMMON_H
+#define COMMON_H
+
+#ifdef DEBUG
+    #include "cork.h"
+#else
+    #define _new new
+#endif
+
+#endif
index 96e72c0777eca2e5fab88b0c7592804a881c2157..92f7cbe3d2a75a515517c7dff34cec6d89516b65 100644 (file)
@@ -1,6 +1,6 @@
 #include "dllexer.h"
 #include "exception.h"
-#include "cork.h"
+#include "common.h"
 
 using namespace std;
 
index de4f91280a29232b311d8a3a11eb117223930b77..77bc480201800b4c9d441811ffd9c3a8c567d3e2 100644 (file)
@@ -1,6 +1,6 @@
 #include "dlparser.h"
 #include "exception.h"
-#include "cork.h"
+#include "common.h"
 
 DLParser::DLParser() : BTParser(_new DLLexer())
 {
@@ -417,22 +417,30 @@ AST* DLParser::Literal(void)
 AST* DLParser::MapLiteral(void)
 {
     AST* ret = NULL;
-
-    match(LBRACE);
-    do
+    AST* child = NULL;
+    try
     {
-        if( lookaheadType(1) == COMMA ) consume();
+        match(LBRACE);
+        do
+        {
+            if( lookaheadType(1) == COMMA ) consume();
 
-        AST* child = Literal();
-        match(SEP);
-        child = _new AST(SEP, 2, child, LogicalExpr());
+            child = Literal();
+            match(SEP);
+            child = _new AST(SEP, 2, child, LogicalExpr());
 
-        ret = ((ret == NULL) ? _new AST(MAP) : ret);
-        ret->addChild(child);
+            ret = ((ret == NULL) ? _new AST(MAP) : ret);
+            ret->addChild(child);
+        }
+        while( lookaheadType(1) == COMMA );
+        match(RBRACE);
+    }
+    catch(Exception e)
+    {
+        if(ret != NULL) delete ret;
+        if(child != NULL) delete child;
+        throw e;
     }
-    while( lookaheadType(1) == COMMA );
-    match(RBRACE);
-
     return ret;
 }
 
index 0fcfb5b8566ee731ed88384a296435b714c71893..7a8182957752d8b767d5136b5af6a3edc313e3ed 100644 (file)
@@ -5,8 +5,15 @@ Pattern::Pattern(const std::list<PatternType_T>& patt, const AST* ast) : pattern
 {
 }
 
+Pattern::Pattern(const Pattern& patt)
+{
+    pattern = patt.pattern;
+    expr_ast = patt.expr_ast->clone();
+}
+
 Pattern::~Pattern()
 {
+    delete expr_ast;
 }
 
 std::list<PatternType_T>::iterator Pattern::begin()
index 225ec024a0e31c4a19a18bb1f1846e22def059d5..33c9be4c1a2879c4b0ba46691d2a55ba00910000 100644 (file)
@@ -26,6 +26,7 @@ class Pattern {
         void apply(AST* cur,std::vector<AST*>& params);
     public:
         Pattern(const std::list<PatternType_T>& patt, const AST* ast);
+        Pattern(const Pattern& patt);
         ~Pattern();
         std::list<PatternType_T>::iterator begin();
         std::list<PatternType_T>::iterator end();
index 35a461436cd3fb281202fdf3a4c2eb37e518b198..019416f6f086d08b69652289fd97e075a248973c 100644 (file)
@@ -5,7 +5,7 @@
 #include "dlparser.h"
 #include "astprinter.h"
 #include "scheme.h"
-#include "cork.h"
+#include "common.h"
 #include "macro.h"
 
 using namespace std;
@@ -51,7 +51,9 @@ int main(int argc, char** argv)
         cerr << "Error: No input files." << endl;
     }
 
+#ifdef DEBUG
     Cork_ReportMemoryLeaks();
+#endif
 
     return ret;
 }