-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added The Device Modeling Language (DML) #7009
Open
TSonono
wants to merge
1
commit into
github-linguist:main
Choose a base branch
from
TSonono:dml
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+314
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
dml 1.4; | ||
|
||
device sample_device; | ||
|
||
param desc = "A sample DML device"; | ||
|
||
param documentation = "This is a sample DML device intended as a sample for" | ||
+ " the Linguist project"; | ||
|
||
import "sample-interface.dml"; | ||
|
||
attribute n_regs_written is (pseudo_attr, uint64_attr) "" { | ||
method get() -> (attr_value_t) { | ||
local uint8 n_written_regs = 0; | ||
foreach reg in (each register_written in (regs)) { | ||
if (reg.has_been_written()) | ||
n_written_regs += 1; | ||
} | ||
return SIM_make_attr_uint64(n_written_regs); | ||
} | ||
|
||
method set(attr_value_t val) throws { | ||
if (SIM_attr_integer(val) != 0) { | ||
log error: "n_regs_written can be only set to 0 to reset written" | ||
+ " status on all registers in the 'regs' bank"; | ||
throw; | ||
} | ||
|
||
foreach reg in (each register_written in (regs)) { | ||
reg.reset_written(); | ||
} | ||
} | ||
} | ||
|
||
implement sample { | ||
saved int arg_sum = 0; | ||
method simple_method(int arg) { | ||
arg_sum += arg; | ||
} | ||
} | ||
|
||
template register_written is (register, write) { | ||
saved bool written; | ||
|
||
method write(uint64 value) default { | ||
this.written = true; | ||
default(value); | ||
} | ||
|
||
shared method has_been_written() -> (bool) { | ||
return this.written; | ||
} | ||
|
||
shared method reset_written() { | ||
this.written = false; | ||
} | ||
} | ||
|
||
bank regs { | ||
param desc = dev.desc + "custom desc"; | ||
register r1 size 4 @ 0x0000 is (read, register_written) { | ||
method read() -> (uint64) { | ||
log info, 3: "read from r1"; | ||
return 42 + sample.arg_sum; | ||
} | ||
} | ||
register r2 size 4 @ 0x0004 is (write, register_written) { | ||
method write(uint64 value) { | ||
log info, 3: "wrote %d to r2", value; | ||
default(value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
dml 1.4; | ||
|
||
header %{ | ||
typedef struct { | ||
void (*simple_method)(conf_object_t *obj, int arg); | ||
} sample_interface_t; | ||
%} | ||
|
||
extern typedef struct { | ||
void (*simple_method)(conf_object_t *obj, int arg); | ||
} sample_interface_t; |
Submodule device-modeling-language
added at
d6a6b4
210 changes: 210 additions & 0 deletions
210
vendor/licenses/git_submodule/device-modeling-language.dep.yml
Large diffs are not rendered by default.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will have no effect as Linguist doesn't know of any other language that uses the
.dml
extension. See my primary comment for more details.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I was under the impression that if this regex didn't match, and given that there are no other languages in linguist that has a
.dml
extension, the language of the file would simply not be recognized.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. Linguist works like a funnel... everything goes in at the top and then works through each of the strategies in decreasing order of specificity until a single language is identified:
linguist/lib/linguist.rb
Lines 51 to 71 in 5fad8d5
As Linguist would only know of the
.dml
extension with this language, it would stop the process there which as as you can see is before the heuristics strategy. It would also however apply this to all.dml
files found on GitHub.There is an exception to this: very generic extensions which we add to the
generic.yml
file. These are checked against the heuristics really early in the extension strategy.Thinking about this further, I think
.dml
is a good candidate to add togeneric.yml
too which would then mean this heuristic is used and will leave the other languages unaffected.Please can you add this extension to the
generic.yml
file. This heuristic can also be improved (we don't need the capturing group and the tiny overhead it brings with it):