-
Notifications
You must be signed in to change notification settings - Fork 5
initial general schema added #1
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
0023e72
9be5104
0f28398
c007f1f
3e3919b
2e5cedb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema#", | ||
| "type": "object", | ||
| "properties": { | ||
| "nodes": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "opcode": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "if", | ||
| "jump", | ||
| "region", | ||
| "start", | ||
| "literal", | ||
| "add", | ||
| "phi", | ||
| "return" | ||
| ] | ||
| }, | ||
| "control": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| } | ||
| }, | ||
| "inputs": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| } | ||
| }, | ||
| "literals": { | ||
| "type": "array", | ||
| "items": { | ||
| "oneOf": [ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be any JavaScript value without limitation.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok. |
||
| { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| }, | ||
| { | ||
| "type": "string", | ||
| "enum": [ | ||
| "ok", | ||
| "not-ok" | ||
| ] | ||
| }, | ||
| { | ||
| "type": "boolean", | ||
| "enum": [ | ||
| true | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": [ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think other fields are required too.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have fixed all your requests. |
||
| "opcode" | ||
| ] | ||
| } | ||
| }, | ||
| "cfg": { | ||
| "type": "object", | ||
| "properties": { | ||
| "blocks": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "node": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| }, | ||
| "nodes": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| } | ||
| }, | ||
| "successors": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "node", | ||
| "nodes", | ||
| "successors" | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "blocks" | ||
| ] | ||
| }, | ||
| "dominance": { | ||
| "type": "object", | ||
| "properties": { | ||
| "blocks": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "properties": { | ||
| "node": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| }, | ||
| "parent": { | ||
| "oneOf": [ | ||
| { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| }, | ||
| { | ||
| "type": "null" | ||
| } | ||
| ] | ||
| }, | ||
| "frontier": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "integer", | ||
| "minimum": 0 | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "node", | ||
| "parent", | ||
| "frontier" | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "blocks" | ||
| ] | ||
| }, | ||
| "registers": { | ||
|
||
| "type": "object", | ||
| "properties": { | ||
| "nodes": { | ||
| "type": "array" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": false, | ||
| "required": [ | ||
| "nodes" | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| var assert = require('assert'); | ||
| var assertText = require('assert-text'); | ||
| var schema = require('../lib/schema.json'); | ||
| var tv4 = require('tv4'); | ||
|
|
||
| assertText.options.trim = true; | ||
|
|
||
|
|
@@ -13,6 +15,12 @@ describe('JSON Pipeline', function() { | |
| p = pipeline.create(); | ||
| }); | ||
|
|
||
| 'p0 p1 p1cfg p2dom'.split(' ').forEach(function (e) { | ||
| it(e + ' should comply with the schema', function() { | ||
| assert.equal(tv4.validate(fixtures.json[e], schema), true); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. Will fix. |
||
| }); | ||
| }); | ||
|
|
||
| it('should render JSON', function() { | ||
| var start = p.add('start'); | ||
| var one = p.add('literal').addLiteral(1); | ||
|
|
||
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 could be actually anything. The user of this framework decides what opcodes should be present.
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.
I could limit it to the string with certain RegExp?Like in your spec?
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.
I'd say that the spec defines some specific opcodes that SHOULD be used, but any other opcode might be used as well.
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.
You design document says:
pcode names MUST not contain
:unless:<platform-name>:prefixshould be used.platform-nameshould not containany characters except ones defined by the set
[a-zA-Z0-9_\-\.]Every node may take several literal inputs, several regular inputs, and
possibly a control input.
We can limit that with schema.
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.
Not sure how the schema could handle:
I think I better change that MUST to SHOULD to make it less confusing.
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.
Maybe something like this?