{"action":"created","comment":{"url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/comments/165649889","pull_request_review_id":93626772,"id":165649889,"diff_hunk":"@@ -35,12 +35,177 @@\n // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n // SOFTWARE.\n \n-use rustc::ty::Ty;\n+use rustc::ty::{Ty, TyCtxt};\n+use rustc::mir::{\n+    START_BLOCK, Mir, BasicBlock, BasicBlockData, Statement, StatementKind,\n+    Rvalue, Place, Terminator, TerminatorKind\n+};\n \n-// Stores a value represented as a vector of bytes, along with its type annotation.\n-// It's important to keep track of a value's type while it is being evaluated,\n-// so that we know how to interpret the bytes.\n+use machine;\n+use machine::{Machine, Address};\n+use primitive::eval_operand;\n+\n+const MEMORY_CAPACITY: usize = 1024;\n+\n+/// Stores a value represented as a vector of bytes, along with its type\n+/// annotation.  It's important to keep track of a value's type while it is\n+/// being evaluated, so that we know how to interpret the bytes.\n+#[derive(Debug, Clone)]\n pub struct TypedVal<'tcx> {\n     pub ty: Ty<'tcx>,\n     pub val: Vec<u8>,\n }\n+\n+/// Builds a VM and starts interpretation from the given MIR function, this is\n+/// normally the main method.\n+pub fn entry_point<'a, 'tcx>(mir: &'tcx Mir<'tcx>,\n+                             tcx: TyCtxt<'a, 'tcx, 'tcx>) {\n+    let m = machine::Memory::new(MEMORY_CAPACITY);\n+    let mut vm = Machine::new(m, tcx);\n+    eval_mir(mir, &mut vm);\n+}\n+\n+/// Evaluates a function call, pushing a new stack frame.\n+pub fn eval_mir<'a, 'tcx>(mir: &'tcx Mir<'tcx>,\n+                          vm: &mut Machine<'a, 'tcx>) {\n+    let frame = machine::Frame::new(mir);\n+    vm.push(frame);\n+    eval_basic_block(START_BLOCK, vm)\n+}\n+\n+/// The easy bit. BasicBlocks are a list of instructions which are guaranteed to\n+/// always be executed sequentially. We just need to iterate over the statement\n+/// list and execute each one in order.\n+fn eval_basic_block(block: BasicBlock,\n+                    vm: &mut Machine) {\n+    let BasicBlockData {\n+        ref statements,\n+        ref terminator,\n+        is_cleanup: _\n+    } = *vm.cur_frame().mir.basic_blocks().get(block).unwrap();\n+\n+    for statement in statements {\n+        eval_statement(block, statement, vm)\n+    }\n+\n+    if let Some(ref terminator) = *terminator {\n+        eval_terminator(terminator, vm);\n+    }\n+}\n+\n+fn eval_statement<'a, 'tcx>(block: BasicBlock,\n+                  statement: &Statement<'tcx>,\n+                  vm: &mut Machine<'a, 'tcx>) {\n+    let Statement {\n+        ref kind,\n+        ..\n+    } = *statement;\n+\n+    match *kind {\n+        StatementKind::Assign(ref place, ref rvalue) => {\n+            eval_assign(block, place, rvalue, vm)\n+        }\n+        StatementKind::StorageLive(_) => {\n+            unimplemented!(\"StorageLive\");\n+        }\n+        StatementKind::StorageDead(_) => {\n+            unimplemented!(\"StorageLive\");","path":"src/interp.rs","position":82,"original_position":82,"commit_id":"7f38994a974fa397bd696204df612d6a8ab136a5","original_commit_id":"7f38994a974fa397bd696204df612d6a8ab136a5","user":{"login":"jacob-hughes","id":10298734,"avatar_url":"https://avatars0.githubusercontent.com/u/10298734?v=4","gravatar_id":"","url":"https://api.github.com/users/jacob-hughes","html_url":"https://github.com/jacob-hughes","followers_url":"https://api.github.com/users/jacob-hughes/followers","following_url":"https://api.github.com/users/jacob-hughes/following{/other_user}","gists_url":"https://api.github.com/users/jacob-hughes/gists{/gist_id}","starred_url":"https://api.github.com/users/jacob-hughes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacob-hughes/subscriptions","organizations_url":"https://api.github.com/users/jacob-hughes/orgs","repos_url":"https://api.github.com/users/jacob-hughes/repos","events_url":"https://api.github.com/users/jacob-hughes/events{/privacy}","received_events_url":"https://api.github.com/users/jacob-hughes/received_events","type":"User","site_admin":false},"body":"Oops","created_at":"2018-02-02T13:55:00Z","updated_at":"2018-02-02T13:55:00Z","html_url":"https://github.com/jacob-hughes/mirkat/pull/5#discussion_r165649889","pull_request_url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/comments/165649889"},"html":{"href":"https://github.com/jacob-hughes/mirkat/pull/5#discussion_r165649889"},"pull_request":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5"}},"in_reply_to_id":165615261},"pull_request":{"url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5","id":166719676,"html_url":"https://github.com/jacob-hughes/mirkat/pull/5","diff_url":"https://github.com/jacob-hughes/mirkat/pull/5.diff","patch_url":"https://github.com/jacob-hughes/mirkat/pull/5.patch","issue_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues/5","number":5,"state":"open","locked":false,"title":"Initial Interpreter Layout","user":{"login":"jacob-hughes","id":10298734,"avatar_url":"https://avatars0.githubusercontent.com/u/10298734?v=4","gravatar_id":"","url":"https://api.github.com/users/jacob-hughes","html_url":"https://github.com/jacob-hughes","followers_url":"https://api.github.com/users/jacob-hughes/followers","following_url":"https://api.github.com/users/jacob-hughes/following{/other_user}","gists_url":"https://api.github.com/users/jacob-hughes/gists{/gist_id}","starred_url":"https://api.github.com/users/jacob-hughes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacob-hughes/subscriptions","organizations_url":"https://api.github.com/users/jacob-hughes/orgs","repos_url":"https://api.github.com/users/jacob-hughes/repos","events_url":"https://api.github.com/users/jacob-hughes/events{/privacy}","received_events_url":"https://api.github.com/users/jacob-hughes/received_events","type":"User","site_admin":false},"body":"This PR lays out most of the groundwork for implementing evaluators for various MIR functions. Once this is merged into master, it _should_ make subsequent PRs speedier and easier to review (It will be easy to separate them into distinct blocks for each new bit of functionality).\r\n\r\nEach commit has a short description about each new addition, please ask questions if it doesn't make sense and be ruthless ;)","created_at":"2018-02-02T05:14:48Z","updated_at":"2018-02-02T13:55:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"241d9feedcec63c0c8cdb40d89fbb5e5af45edd1","assignee":{"login":"ltratt","id":20318,"avatar_url":"https://avatars1.githubusercontent.com/u/20318?v=4","gravatar_id":"","url":"https://api.github.com/users/ltratt","html_url":"https://github.com/ltratt","followers_url":"https://api.github.com/users/ltratt/followers","following_url":"https://api.github.com/users/ltratt/following{/other_user}","gists_url":"https://api.github.com/users/ltratt/gists{/gist_id}","starred_url":"https://api.github.com/users/ltratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ltratt/subscriptions","organizations_url":"https://api.github.com/users/ltratt/orgs","repos_url":"https://api.github.com/users/ltratt/repos","events_url":"https://api.github.com/users/ltratt/events{/privacy}","received_events_url":"https://api.github.com/users/ltratt/received_events","type":"User","site_admin":false},"assignees":[{"login":"ltratt","id":20318,"avatar_url":"https://avatars1.githubusercontent.com/u/20318?v=4","gravatar_id":"","url":"https://api.github.com/users/ltratt","html_url":"https://github.com/ltratt","followers_url":"https://api.github.com/users/ltratt/followers","following_url":"https://api.github.com/users/ltratt/following{/other_user}","gists_url":"https://api.github.com/users/ltratt/gists{/gist_id}","starred_url":"https://api.github.com/users/ltratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ltratt/subscriptions","organizations_url":"https://api.github.com/users/ltratt/orgs","repos_url":"https://api.github.com/users/ltratt/repos","events_url":"https://api.github.com/users/ltratt/events{/privacy}","received_events_url":"https://api.github.com/users/ltratt/received_events","type":"User","site_admin":false},{"login":"vext01","id":604955,"avatar_url":"https://avatars2.githubusercontent.com/u/604955?v=4","gravatar_id":"","url":"https://api.github.com/users/vext01","html_url":"https://github.com/vext01","followers_url":"https://api.github.com/users/vext01/followers","following_url":"https://api.github.com/users/vext01/following{/other_user}","gists_url":"https://api.github.com/users/vext01/gists{/gist_id}","starred_url":"https://api.github.com/users/vext01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vext01/subscriptions","organizations_url":"https://api.github.com/users/vext01/orgs","repos_url":"https://api.github.com/users/vext01/repos","events_url":"https://api.github.com/users/vext01/events{/privacy}","received_events_url":"https://api.github.com/users/vext01/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"milestone":null,"commits_url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5/commits","review_comments_url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5/comments","review_comment_url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues/5/comments","statuses_url":"https://api.github.com/repos/jacob-hughes/mirkat/statuses/7f38994a974fa397bd696204df612d6a8ab136a5","head":{"label":"jacob-hughes:initial_interp_layout","ref":"initial_interp_layout","sha":"7f38994a974fa397bd696204df612d6a8ab136a5","user":{"login":"jacob-hughes","id":10298734,"avatar_url":"https://avatars0.githubusercontent.com/u/10298734?v=4","gravatar_id":"","url":"https://api.github.com/users/jacob-hughes","html_url":"https://github.com/jacob-hughes","followers_url":"https://api.github.com/users/jacob-hughes/followers","following_url":"https://api.github.com/users/jacob-hughes/following{/other_user}","gists_url":"https://api.github.com/users/jacob-hughes/gists{/gist_id}","starred_url":"https://api.github.com/users/jacob-hughes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacob-hughes/subscriptions","organizations_url":"https://api.github.com/users/jacob-hughes/orgs","repos_url":"https://api.github.com/users/jacob-hughes/repos","events_url":"https://api.github.com/users/jacob-hughes/events{/privacy}","received_events_url":"https://api.github.com/users/jacob-hughes/received_events","type":"User","site_admin":false},"repo":{"id":118784974,"name":"mirkat","full_name":"jacob-hughes/mirkat","owner":{"login":"jacob-hughes","id":10298734,"avatar_url":"https://avatars0.githubusercontent.com/u/10298734?v=4","gravatar_id":"","url":"https://api.github.com/users/jacob-hughes","html_url":"https://github.com/jacob-hughes","followers_url":"https://api.github.com/users/jacob-hughes/followers","following_url":"https://api.github.com/users/jacob-hughes/following{/other_user}","gists_url":"https://api.github.com/users/jacob-hughes/gists{/gist_id}","starred_url":"https://api.github.com/users/jacob-hughes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacob-hughes/subscriptions","organizations_url":"https://api.github.com/users/jacob-hughes/orgs","repos_url":"https://api.github.com/users/jacob-hughes/repos","events_url":"https://api.github.com/users/jacob-hughes/events{/privacy}","received_events_url":"https://api.github.com/users/jacob-hughes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacob-hughes/mirkat","description":"A rust MIR interpreter","fork":false,"url":"https://api.github.com/repos/jacob-hughes/mirkat","forks_url":"https://api.github.com/repos/jacob-hughes/mirkat/forks","keys_url":"https://api.github.com/repos/jacob-hughes/mirkat/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacob-hughes/mirkat/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacob-hughes/mirkat/teams","hooks_url":"https://api.github.com/repos/jacob-hughes/mirkat/hooks","issue_events_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues/events{/number}","events_url":"https://api.github.com/repos/jacob-hughes/mirkat/events","assignees_url":"https://api.github.com/repos/jacob-hughes/mirkat/assignees{/user}","branches_url":"https://api.github.com/repos/jacob-hughes/mirkat/branches{/branch}","tags_url":"https://api.github.com/repos/jacob-hughes/mirkat/tags","blobs_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacob-hughes/mirkat/statuses/{sha}","languages_url":"https://api.github.com/repos/jacob-hughes/mirkat/languages","stargazers_url":"https://api.github.com/repos/jacob-hughes/mirkat/stargazers","contributors_url":"https://api.github.com/repos/jacob-hughes/mirkat/contributors","subscribers_url":"https://api.github.com/repos/jacob-hughes/mirkat/subscribers","subscription_url":"https://api.github.com/repos/jacob-hughes/mirkat/subscription","commits_url":"https://api.github.com/repos/jacob-hughes/mirkat/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacob-hughes/mirkat/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacob-hughes/mirkat/contents/{+path}","compare_url":"https://api.github.com/repos/jacob-hughes/mirkat/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacob-hughes/mirkat/merges","archive_url":"https://api.github.com/repos/jacob-hughes/mirkat/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacob-hughes/mirkat/downloads","issues_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues{/number}","pulls_url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls{/number}","milestones_url":"https://api.github.com/repos/jacob-hughes/mirkat/milestones{/number}","notifications_url":"https://api.github.com/repos/jacob-hughes/mirkat/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacob-hughes/mirkat/labels{/name}","releases_url":"https://api.github.com/repos/jacob-hughes/mirkat/releases{/id}","deployments_url":"https://api.github.com/repos/jacob-hughes/mirkat/deployments","created_at":"2018-01-24T15:37:02Z","updated_at":"2018-01-31T11:40:35Z","pushed_at":"2018-02-02T05:14:49Z","git_url":"git://github.com/jacob-hughes/mirkat.git","ssh_url":"git@github.com:jacob-hughes/mirkat.git","clone_url":"https://github.com/jacob-hughes/mirkat.git","svn_url":"https://github.com/jacob-hughes/mirkat","homepage":null,"size":18,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"jacob-hughes:master","ref":"master","sha":"1b704d870b6da764de6d7786b243fa314fc39ed8","user":{"login":"jacob-hughes","id":10298734,"avatar_url":"https://avatars0.githubusercontent.com/u/10298734?v=4","gravatar_id":"","url":"https://api.github.com/users/jacob-hughes","html_url":"https://github.com/jacob-hughes","followers_url":"https://api.github.com/users/jacob-hughes/followers","following_url":"https://api.github.com/users/jacob-hughes/following{/other_user}","gists_url":"https://api.github.com/users/jacob-hughes/gists{/gist_id}","starred_url":"https://api.github.com/users/jacob-hughes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacob-hughes/subscriptions","organizations_url":"https://api.github.com/users/jacob-hughes/orgs","repos_url":"https://api.github.com/users/jacob-hughes/repos","events_url":"https://api.github.com/users/jacob-hughes/events{/privacy}","received_events_url":"https://api.github.com/users/jacob-hughes/received_events","type":"User","site_admin":false},"repo":{"id":118784974,"name":"mirkat","full_name":"jacob-hughes/mirkat","owner":{"login":"jacob-hughes","id":10298734,"avatar_url":"https://avatars0.githubusercontent.com/u/10298734?v=4","gravatar_id":"","url":"https://api.github.com/users/jacob-hughes","html_url":"https://github.com/jacob-hughes","followers_url":"https://api.github.com/users/jacob-hughes/followers","following_url":"https://api.github.com/users/jacob-hughes/following{/other_user}","gists_url":"https://api.github.com/users/jacob-hughes/gists{/gist_id}","starred_url":"https://api.github.com/users/jacob-hughes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacob-hughes/subscriptions","organizations_url":"https://api.github.com/users/jacob-hughes/orgs","repos_url":"https://api.github.com/users/jacob-hughes/repos","events_url":"https://api.github.com/users/jacob-hughes/events{/privacy}","received_events_url":"https://api.github.com/users/jacob-hughes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacob-hughes/mirkat","description":"A rust MIR interpreter","fork":false,"url":"https://api.github.com/repos/jacob-hughes/mirkat","forks_url":"https://api.github.com/repos/jacob-hughes/mirkat/forks","keys_url":"https://api.github.com/repos/jacob-hughes/mirkat/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacob-hughes/mirkat/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacob-hughes/mirkat/teams","hooks_url":"https://api.github.com/repos/jacob-hughes/mirkat/hooks","issue_events_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues/events{/number}","events_url":"https://api.github.com/repos/jacob-hughes/mirkat/events","assignees_url":"https://api.github.com/repos/jacob-hughes/mirkat/assignees{/user}","branches_url":"https://api.github.com/repos/jacob-hughes/mirkat/branches{/branch}","tags_url":"https://api.github.com/repos/jacob-hughes/mirkat/tags","blobs_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacob-hughes/mirkat/statuses/{sha}","languages_url":"https://api.github.com/repos/jacob-hughes/mirkat/languages","stargazers_url":"https://api.github.com/repos/jacob-hughes/mirkat/stargazers","contributors_url":"https://api.github.com/repos/jacob-hughes/mirkat/contributors","subscribers_url":"https://api.github.com/repos/jacob-hughes/mirkat/subscribers","subscription_url":"https://api.github.com/repos/jacob-hughes/mirkat/subscription","commits_url":"https://api.github.com/repos/jacob-hughes/mirkat/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacob-hughes/mirkat/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacob-hughes/mirkat/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacob-hughes/mirkat/contents/{+path}","compare_url":"https://api.github.com/repos/jacob-hughes/mirkat/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacob-hughes/mirkat/merges","archive_url":"https://api.github.com/repos/jacob-hughes/mirkat/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacob-hughes/mirkat/downloads","issues_url":"https://api.github.com/repos/jacob-hughes/mirkat/issues{/number}","pulls_url":"https://api.github.com/repos/jacob-hughes/mirkat/pulls{/number}","milestones_url":"https://api.github.com/repos/jacob-hughes/mirkat/milestones{/number}","notifications_url":"https://api.github.com/repos/jacob-hughes/mirkat/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacob-hughes/mirkat/labels{/name}","releases_url":"https://api.github.com/repos/jacob-hughes/mirkat/releases{/id}","deployments_url":"https://api.github.com/repos/jacob-hughes/mirkat/deployments","created_at":"2018-01-24T15:37:02Z","updated_at":"2018-01-31T11:40:35Z","pushed_at":"2018-02-02T05:14:49Z","git_url":"git://github.com/jacob-hughes/mirkat.git","ssh_url":"git@github.com:jacob-hughes/mirkat.git","clone_url":"https://github.com/jacob-hughes/mirkat.git","svn_url":"https://github.com/jacob-hughes/mirkat","homepage":null,"size":18,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":4,"license":null,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5"},"html":{"href":"https://github.com/jacob-hughes/mirkat/pull/5"},"issue":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/issues/5"},"comments":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/jacob-hughes/mirkat/statuses/7f38994a974fa397bd696204df612d6a8ab136a5"}},"author_association":"OWNER"}}
{"actor":{"display_login":"jacob-hughes"}}