Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Show default module name if declaration missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugen Wissner authored and Eugen Wissner committed Mar 28, 2022
1 parent b0a232a commit 5f3cd34
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 247 deletions.
35 changes: 20 additions & 15 deletions make.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
require 'fileutils'
require 'net/http'

BIN_PATH = Pathname.new 'tools/dmd2/linux/bin64'
DC = Pathname.new(ENV.fetch 'DC', 'tools/dmd2/linux/bin64/dmd').expand_path
BIN_PATH = DC.dirname

def make_arguments(name, arguments)
arguments.map do |argument|
Expand Down Expand Up @@ -62,36 +63,38 @@ def build_frontend(version = 'debug')

Dir.mkdir 'build' unless Dir.exist? 'build'

system((BIN_PATH + 'dmd').to_s,
system(DC.to_s,
"-#{version}",
'-lib',
*arguments,
exception: true)
end

def dub(command, arguments = [])
system({ 'DC' => DC.to_s },
(BIN_PATH + 'dub').to_s,
command, *arguments,
exception: true)
end

def build(version = 'debug')
build_frontend unless File.exist? 'build/dmd.a'
config = version == 'unittest' ? 'unittest' : 'executable'

system((BIN_PATH + 'dub').to_s,
'build', "--build=#{version}",
"--config=#{config}",
exception: true)
dub 'build', ["--build=#{version}", "--config=#{config}"]
end

def clean
FileUtils.rm_f Dir.glob('build/*')

system((BIN_PATH + 'dub').to_s, 'clean', exception: true)
dub 'clean'
end

(ARGV.empty? ? ['d'] : ARGV).each do |argument|
case argument
when 'd'
when 'clean'
clean
build
when 'release'
build 'release'
when 'release', 'debug'
build argument
when 'run'
build 'debug'
system 'build/cogito', 'sample/sample.d'
Expand All @@ -100,10 +103,12 @@ def clean
system 'build/test', '-s'
when 'install'
install_frontend
when 'ts'
system 'npx', 'cognitive-complexity-ts-json', 'sample/sample.ts'
else
raise "Command „#{argument}“ doesn't exist"
puts <<~CMD
Command „#{argument}“ doesn't exist.
Available commands are: clean, release, debug, unittest, install.
CMD
exit 1
end
end

Expand Down
11 changes: 0 additions & 11 deletions package.json

This file was deleted.

3 changes: 0 additions & 3 deletions sample/sample.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/cogito/visitor.d
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,9 @@ extern(C++) final class CognitiveVisitor : SemanticTimeTransitiveVisitor
{
debug writeln("Module declaration ", moduleDeclaration);

this.source_.filename = moduleDeclaration.md.toString.idup;
this.source_.filename = moduleDeclaration.md is null
? "app"
: moduleDeclaration.md.toString.idup;

super.visit(moduleDeclaration);
}
Expand Down
217 changes: 0 additions & 217 deletions yarn.lock

This file was deleted.

0 comments on commit 5f3cd34

Please sign in to comment.