daedalus-core 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88b4b37209072707c1e9b3d1512404f3bf7d6c19
4
- data.tar.gz: 2a339fc1ce031a48f9cdde337222d258d433b6b1
3
+ metadata.gz: a6062bb9e0d98bf16f54127b8e21d9294f4e56c1
4
+ data.tar.gz: f67aef0682be44b26cccb52a7d8901f0fb467fec
5
5
  SHA512:
6
- metadata.gz: 2fdd7ab10df0925fc984a914b78d86c5dfe5c582ade40d0ed92ccc1e0123d8208bd72e1aecb5522fb69bb12ad1a18a6b825bdd1424413fa753415043db14a7e7
7
- data.tar.gz: fc0d43276ba10c105bd7912fc87607b22223578744dbad1a09bec0fa94468b8b9c0d3d2e4bc375383a1449ed2389baad918aceb01e8fe20de79b560209397335
6
+ metadata.gz: 5b6f4187ce6469758bdbd332c4de348155a0af8212652dad278ddf4703332a96f63a4f181e631f842e5db493d97820ad393697708b689e135238699ecaf25518
7
+ data.tar.gz: 15830e804c19c89e8df2b38dba98fba60fbe3eea04ff9f4a586021edd00fd19d5632f48aa4d0e94aef23ac41cc1a77baddbd693f655a254c7118f385cb3cbd08
@@ -25,13 +25,53 @@ class DependencyGrapher
25
25
 
26
26
  class ExpressionEvaluator
27
27
  def initialize(expression)
28
- @expression = expression
28
+ @expression = expression.strip
29
29
  end
30
30
 
31
- # TODO: when melbourne is running in MRI, use it to parse
32
- # the expression and then evaluate it.
33
31
  def evaluate(defines)
34
- @expression == "0" ? false : true
32
+ # Stage1: find 'defined's and evaluate
33
+ # replace defined with boolean evaluation value
34
+ @expression.gsub!(/(defined\(.+?\))/) { |expr|
35
+ defkey = expr.match(/\((.+?)\)/)[1]
36
+ if defines.include?(defkey)
37
+ 'true'
38
+ else
39
+ 'false'
40
+ end
41
+ }
42
+ # Stage2: scan macro-defined keywords
43
+ # replace with actual value (true or false)
44
+ # this covers patterns like __clang__ and __x86_64__
45
+ @expression.gsub!(/__[A-Za-z0-9_]+__/) { |expr|
46
+ if defines.include?(expr)
47
+ defines[expr].to_s
48
+ elsif integer?(expr)
49
+ expr
50
+ else
51
+ '0'
52
+ end
53
+ }
54
+
55
+ # this covers other patters.
56
+ @expression.gsub!(/[A-Z0-9_]{4,}/) { |expr|
57
+ if defines.include?(expr)
58
+ defines[expr].to_s
59
+ elsif integer?(expr)
60
+ expr
61
+ else
62
+ '0'
63
+ end
64
+ }
65
+ # Stage3: Evaluate with ruby eval()
66
+ eval(@expression)
67
+ end
68
+
69
+ private
70
+ def integer?(str)
71
+ Integer(str)
72
+ true
73
+ rescue
74
+ false
35
75
  end
36
76
  end
37
77
 
@@ -252,7 +292,6 @@ class DependencyGrapher
252
292
  class Define < Node
253
293
  def initialize(macro, parser)
254
294
  super parser
255
-
256
295
  macro.strip!
257
296
  if index = macro.index(" ")
258
297
  @name = macro[0..index-1]
@@ -389,11 +428,22 @@ class DependencyGrapher
389
428
  def parse(lines)
390
429
  @line = 0
391
430
 
392
- lines.each do |line|
393
- @line += 1
394
- m = line.match(/^\s*#(include|ifdef|ifndef|endif|else|define|undef|if|elif)(.*)$/)
431
+ inlined_line = ""
432
+ unless lines.empty?
433
+ while (line = lines.shift.chomp(''))
434
+ @line += 1
435
+ line.rstrip!
436
+ if line.end_with?('\\')
437
+ # continue reading if line ends in \
438
+ inlined_line += line.chop
439
+ else
440
+ # stop reading
441
+ inlined_line += line
442
+ break
443
+ end
444
+ end
395
445
 
396
- # TODO: continue reading if line ends in \
446
+ m = inlined_line.match(/^\s*#(include|ifdef|ifndef|endif|else|define|undef|if|elif)(.*)$/)
397
447
 
398
448
  send :"process_#{m[1]}", m[2] if m
399
449
  end
@@ -1,3 +1,3 @@
1
1
  module Daedalus
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,39 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daedalus-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-15 00:00:00.000000000 Z
11
+ date: 2015-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ type: :development
14
15
  name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
+ version_requirements: !ruby/object:Gem::Requirement
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
20
  version: '0.9'
20
- type: :development
21
21
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
22
+ requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
27
  - !ruby/object:Gem::Dependency
28
+ type: :development
28
29
  name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
+ version_requirements: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
34
  version: '2.8'
34
- type: :development
35
35
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
36
+ requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
@@ -82,9 +82,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  requirements: []
84
84
  rubyforge_project:
85
- rubygems_version: 2.2.2
85
+ rubygems_version: 2.4.5
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Daedalus is a build system extracted from Rubinius. Almost no functionality
89
89
  has been implemented. This is very alpha.
90
90
  test_files: []
91
+ has_rdoc: true