yadriggy 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,10 @@ require 'yadriggy/type'
6
6
 
7
7
  module Yadriggy
8
8
 
9
- # Type checker for ASTree
9
+ # Type checker for ASTree.
10
+ # This provides several basic methods and utility classes for type checking.
11
+ # It does not specify any specific typing rules. Define a subclass of
12
+ # {TypeChecker} and write typing rules there.
10
13
  #
11
14
  # A type object used by TypeChecker can be an instance of any subclass
12
15
  # of Type. It does not have to necessarily be an object representing
@@ -81,7 +84,7 @@ module Yadriggy
81
84
  @parent&.context
82
85
  end
83
86
 
84
- # @private
87
+ # @api private
85
88
  class BaseTypeEnv < TypeEnv
86
89
  def initialize(clazz)
87
90
  super(nil)
@@ -192,7 +195,7 @@ module Yadriggy
192
195
 
193
196
  # Applies typing rules to the given AST.
194
197
  # It returns the type of the AST or throws
195
- # a CheckError.
198
+ # a {CheckError}.
196
199
  # This is the entry point of the type checker. It may also
197
200
  # type the other ASTs invoked in the given AST.
198
201
  #
@@ -211,7 +214,7 @@ module Yadriggy
211
214
  TypeEnv::BaseTypeEnv.new(klass)
212
215
  end
213
216
 
214
- # @private
217
+ # @api private
215
218
  # Internal-use only. Don't use this method. Use type().
216
219
  #
217
220
  def check(an_ast, ast_tenv=nil)
@@ -245,7 +248,7 @@ module Yadriggy
245
248
  #
246
249
  # @param [ASTnode|nil] an_ast an AST.
247
250
  # @param [Type] a_type a type.
248
- # @param [Type|nil] the given type `a_type`.
251
+ # @return [Type|nil] the given type `a_type`.
249
252
  def type_as(an_ast, a_type)
250
253
  if an_ast.nil?
251
254
  DynType
@@ -254,6 +257,16 @@ module Yadriggy
254
257
  end
255
258
  end
256
259
 
260
+ # Gets the type of the given AST if its type has been
261
+ # already determined by {.type}. Only the memoized types
262
+ # are returned.
263
+ #
264
+ # @param [ASTnode] an_ast an AST.
265
+ # @return [Type|nil] the type or `nil` if not found.
266
+ def type?(an_ast)
267
+ @typetable[an_ast]
268
+ end
269
+
257
270
  def type_assert(is_valid, errmsg='')
258
271
  error_found!(@current_ast, errmsg) unless is_valid
259
272
  end
@@ -1,5 +1,5 @@
1
1
  # Copyright (C) 2017- Shigeru Chiba. All rights reserved.
2
2
 
3
3
  module Yadriggy
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{library for building a DSL embedded in Ruby.}
13
13
 
14
- spec.description = %q{Yadriggy builds the abstract syntax tree (AST) of a method, checks its syntax and types, and runs it. When checking the syntax and types, it is treated as the code written in a domain specific language (DSL). It also provide a simple DSL for computation offloading from Ruby to C.}
14
+ spec.description = %q{Yadriggy builds the abstract syntax tree (AST) of a method, checks its syntax and types, and runs it. When checking the syntax and types, it is treated as the code written in a domain specific language (DSL). It also provide simple DSLs for computation offloading from Ruby to C, Python, etc.}
15
15
 
16
16
  spec.homepage = "https://github.com/csg-tokyo/yadriggy"
17
17
  spec.license = "MIT"
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.13"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "yard"
31
32
  # spec.add_development_dependency "minitest", "~> 5.0"
32
33
  spec.add_development_dependency "test-unit", "~> 3.2.5"
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yadriggy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shigeru Chiba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-07 00:00:00.000000000 Z
11
+ date: 2018-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: test-unit
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -82,14 +96,15 @@ dependencies:
82
96
  version: 3.2.5
83
97
  description: Yadriggy builds the abstract syntax tree (AST) of a method, checks its
84
98
  syntax and types, and runs it. When checking the syntax and types, it is treated
85
- as the code written in a domain specific language (DSL). It also provide a simple
86
- DSL for computation offloading from Ruby to C.
99
+ as the code written in a domain specific language (DSL). It also provide simple
100
+ DSLs for computation offloading from Ruby to C, Python, etc.
87
101
  email:
88
102
  executables: []
89
103
  extensions: []
90
104
  extra_rdoc_files: []
91
105
  files:
92
106
  - ".gitignore"
107
+ - ".yardopts"
93
108
  - Gemfile
94
109
  - LICENSE
95
110
  - README.md
@@ -114,6 +129,11 @@ files:
114
129
  - lib/yadriggy/eval_all.rb
115
130
  - lib/yadriggy/pretty_print.rb
116
131
  - lib/yadriggy/printer.rb
132
+ - lib/yadriggy/py.rb
133
+ - lib/yadriggy/py/codegen.rb
134
+ - lib/yadriggy/py/import.rb
135
+ - lib/yadriggy/py/py_typechecker.rb
136
+ - lib/yadriggy/py/python.rb
117
137
  - lib/yadriggy/ruby_typecheck.rb
118
138
  - lib/yadriggy/ruby_typeinfer.rb
119
139
  - lib/yadriggy/source_code.rb