Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/libbash:master commit in: /
Date: Sun, 08 May 2011 13:08:14
Message-Id: d99d179bbe397cf69bca41b0dd3962b1676676f9.betelgeuse@gentoo
1 commit: d99d179bbe397cf69bca41b0dd3962b1676676f9
2 Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
3 AuthorDate: Sun May 8 13:04:54 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Sun May 8 13:04:54 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=d99d179b
7
8 Merge remote-tracking branch 'mu/variable_setup'
9
10 Conflicts:
11 src/builtins/source_builtin.cpp
12
13
14 .gitignore | 2 +
15 Makefile.am | 15 ++-
16 configure.ac | 2 +
17 src/builtins/source_builtin.cpp | 19 ++-
18 src/core/symbols.hpp | 2 +-
19 src/core/tests/symbols_test.cpp | 2 +
20 src/libbash.cpp | 5 +
21 src/libbash.h | 3 +-
22 utils/command_line.cpp | 88 +++++++++
23 utils/command_line.h | 62 ++++++
24 utils/instruo.cpp | 251 ++++++++++++++++++++++++
25 utils/{metadata_generator.cpp => metadata.cpp} | 35 +---
26 src/common.h => utils/metadata.h | 20 +-
27 utils/metadata_generator.cpp | 84 +--------
28 14 files changed, 465 insertions(+), 125 deletions(-)
29
30 diff --cc src/builtins/source_builtin.cpp
31 index 1e82c77,6ba6b11..277eb94
32 --- a/src/builtins/source_builtin.cpp
33 +++ b/src/builtins/source_builtin.cpp
34 @@@ -26,8 -26,8 +26,9 @@@
35
36 #include <fstream>
37 #include <string>
38 + #include <unordered_map>
39
40 +#include "builtins/builtin_exceptions.h"
41 #include "cppbash_builtin.h"
42 #include "core/interpreter.h"
43 #include "core/interpreter_exception.h"
44 @@@ -40,16 -42,17 +43,22 @@@ int source_builtin::exec(const std::vec
45
46 // we need fix this to pass extra arguments as positional parameters
47 const std::string& path = bash_args[0];
48 - std::ifstream input(path);
49 - if(!input)
50 - throw interpreter_exception(path + " can't be read");
51
52 - bash_ast ast(input);
53 + auto& stored_ast = ast_cache[path];
54 + if(!stored_ast)
55 + {
56 + std::ifstream input(path);
57 + if(!input)
58 + throw interpreter_exception(path + " can't be read");
59 +
60 + stored_ast.reset(new bash_ast(input));
61 + }
62 - stored_ast->interpret_with(_walker);
63 ++
64 + try
65 + {
66 - ast.interpret_with(_walker);
67 ++ stored_ast->interpret_with(_walker);
68 + }
69 + catch(return_exception& e) {}
70
71 return _walker.get_status();
72 }