iv-phonic 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -20,8 +20,8 @@ ext/include/iv/errors.h
20
20
  ext/include/iv/ast-visitor.h
21
21
  ext/include/iv/token.h
22
22
  ext/include/iv/enable_if.h
23
- ext/include/iv/source.h
24
23
  ext/include/iv/any.h
24
+ ext/include/iv/keyword.h
25
25
  ext/include/iv/cmdline.h
26
26
  ext/include/iv/xorshift.h
27
27
  ext/include/iv/location.h
@@ -30,14 +30,13 @@ ext/include/iv/algorithm.h
30
30
  ext/include/iv/ustring.h
31
31
  ext/include/iv/ast-fwd.h
32
32
  ext/include/iv/utils.h
33
+ ext/include/iv/ast-info.h
33
34
  ext/include/iv/alloc.h
34
35
  ext/include/iv/chars.h
35
36
  ext/include/iv/fixedcontainer.h
36
37
  ext/include/iv/ustringpiece.h
37
38
  ext/include/iv/ast-serializer.h
38
39
  ext/include/iv/ucdata.h
39
- ext/iv/phonic/rnode.h
40
- ext/iv/phonic/ast.h
41
40
  ext/iv/phonic/factory.h
42
41
  ext/iv/phonic/parser.h
43
42
  ext/iv/phonic/encoding.h
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ directory "ext/include/iv"
10
10
 
11
11
  HOE = Hoe.spec 'iv-phonic' do
12
12
  developer('Constellation', 'utatane.tea@gmail.com')
13
- self.version = '0.0.3'
13
+ self.version = '0.0.5'
14
14
  self.readme_file = 'README.rdoc'
15
15
  self.history_file = 'ChangeLog'
16
16
  self.extra_rdoc_files = FileList['*.rdoc']
@@ -117,12 +117,11 @@ class Space {
117
117
  : arena_(&init_arenas_[0]),
118
118
  start_malloced_(NULL),
119
119
  malloced_() {
120
- unsigned int c = 0;
121
- for (; c < kInitArenas-1; ++c) {
120
+ for (std::size_t c = 0; c < N-1; ++c) {
122
121
  init_arenas_[c].SetNext(&init_arenas_[c+1]);
123
122
  }
124
123
  }
125
- virtual ~Space() {
124
+ ~Space() {
126
125
  if (start_malloced_) {
127
126
  Arena *now = start_malloced_, *next = start_malloced_;
128
127
  while (now) {
@@ -161,7 +160,7 @@ class Space {
161
160
  }
162
161
  }
163
162
 
164
- virtual inline void Clear() {
163
+ inline void Clear() {
165
164
  arena_ = init_arenas_;
166
165
  std::for_each(malloced_.begin(), malloced_.end(), &Malloced::Delete);
167
166
  malloced_.clear();
@@ -196,5 +195,13 @@ class Space {
196
195
  std::vector<void*>malloced_;
197
196
  };
198
197
 
198
+ // surpress compiler warning
199
+ template<>
200
+ inline Space<1>::Space()
201
+ : arena_(&init_arenas_[0]),
202
+ start_malloced_(NULL),
203
+ malloced_() {
204
+ }
205
+
199
206
  } } // namespace iv::core
200
207
  #endif // _IV_ALLOC_H_
@@ -12,10 +12,10 @@ namespace iv {
12
12
  namespace core {
13
13
  namespace ast {
14
14
 
15
- template<std::size_t N, typename Factory>
16
- class BasicAstFactory : public Space<N> {
15
+ template<typename Factory>
16
+ class BasicAstFactory {
17
17
  public:
18
- typedef BasicAstFactory<N, Factory> this_type;
18
+ typedef BasicAstFactory<Factory> this_type;
19
19
 
20
20
  #define V(AST) typedef typename ast::AST<Factory> AST;
21
21
  AST_NODE_LIST(V)
@@ -28,8 +28,7 @@ class BasicAstFactory : public Space<N> {
28
28
  #undef V
29
29
 
30
30
  BasicAstFactory()
31
- : Space<N>(),
32
- undefined_instance_(
31
+ : undefined_instance_(
33
32
  new(static_cast<Factory*>(this))Undefined()),
34
33
  empty_statement_instance_(
35
34
  new(static_cast<Factory*>(this))EmptyStatement()),
@@ -90,8 +89,14 @@ class BasicAstFactory : public Space<N> {
90
89
  ObjectLiteral(static_cast<Factory*>(this));
91
90
  }
92
91
 
92
+ template<typename T>
93
+ T** NewPtr() {
94
+ return new (static_cast<Factory*>(this)->New(sizeof(T*))) T*(NULL);
95
+ }
96
+
93
97
  Identifiers* NewLabels() {
94
- return new (Space<N>::New(sizeof(Identifiers)))
98
+ void* place = static_cast<Factory*>(this)->New(sizeof(Identifiers));
99
+ return new (place)
95
100
  Identifiers(
96
101
  typename Identifiers::allocator_type(static_cast<Factory*>(this)));
97
102
  }
@@ -128,6 +133,10 @@ class BasicAstFactory : public Space<N> {
128
133
  return new (static_cast<Factory*>(this)) FunctionStatement(func);
129
134
  }
130
135
 
136
+ FunctionDeclaration* NewFunctionDeclaration(FunctionLiteral* func) {
137
+ return new (static_cast<Factory*>(this)) FunctionDeclaration(func);
138
+ }
139
+
131
140
  Block* NewBlock() {
132
141
  return new (static_cast<Factory*>(this)) Block(static_cast<Factory*>(this));
133
142
  }
@@ -24,6 +24,7 @@ V(SwitchStatement)\
24
24
  V(ThrowStatement)\
25
25
  V(TryStatement)\
26
26
  V(LabelledStatement)\
27
+ V(FunctionDeclaration)
27
28
 
28
29
  #define STATEMENT_NODE_LIST(V)\
29
30
  V(Statement)\
@@ -98,5 +99,6 @@ template<typename Factory>\
98
99
  class AST;
99
100
  AST_NODE_LIST(V)
100
101
  #undef V
102
+
101
103
  } } } // namespace iv::core::ast
102
104
  #endif // _IV_AST_FWD_H_
@@ -0,0 +1,21 @@
1
+ #ifndef _IV_AST_INFO_H_
2
+ #define _IV_AST_INFO_H_
3
+ #include "ast.h"
4
+ #include "space.h"
5
+ namespace iv {
6
+ namespace core {
7
+ namespace ast {
8
+ template<typename Factory>
9
+ struct AstInfo {
10
+ #define V(AST) typedef typename AST<Factory> AST;
11
+ AST_NODE_LIST(V)
12
+ #undef V
13
+ #define V(X, XS) typedef typename SpaceVector<Factory, X *>::type XS;
14
+ AST_LIST_LIST(V)
15
+ #undef V
16
+ #define V(S) typedef typename SpaceUString<Factory>::type S;
17
+ AST_STRING(V)
18
+ #undef V
19
+ };
20
+ } } } // namespace iv::core::ast
21
+ #endif // _IV_AST_INFO_H_
@@ -71,6 +71,12 @@ class AstSerializer: public AstVisitor<Factory>::const_type {
71
71
  Append('}');
72
72
  }
73
73
 
74
+ void Visit(const FunctionDeclaration* func) {
75
+ Append("{\"type\":\"function_declaration\",\"def\":");
76
+ func->function()->Accept(this);
77
+ Append('}');
78
+ }
79
+
74
80
  void Visit(const VariableStatement* var) {
75
81
  Append("{\"type\":");
76
82
  if (var->IsConst()) {
@@ -39,6 +39,7 @@ class BasicAstVisitor
39
39
  virtual ~BasicAstVisitor() = 0;
40
40
  virtual void Visit(typename add<Block<Factory> >::type block) = 0; //NOLINT
41
41
  virtual void Visit(typename add<FunctionStatement<Factory> >::type func) = 0; //NOLINT
42
+ virtual void Visit(typename add<FunctionDeclaration<Factory> >::type func) = 0; //NOLINT
42
43
  virtual void Visit(typename add<VariableStatement<Factory> >::type var) = 0; //NOLINT
43
44
  virtual void Visit(typename add<EmptyStatement<Factory> >::type empty) = 0; //NOLINT
44
45
  virtual void Visit(typename add<IfStatement<Factory> >::type ifstmt) = 0; //NOLINT