diff --git a/.gitignore b/.gitignore index e442d3c..00eed58 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ node_modules #nodejs things node_modules npm-debug.log + +#vim swap files +*.swp diff --git a/instructions/adding-labels-cropped.png b/instructions/adding-labels-cropped.png new file mode 100644 index 0000000..dec0e1d Binary files /dev/null and b/instructions/adding-labels-cropped.png differ diff --git a/instructions/adding-labels.png b/instructions/adding-labels.png new file mode 100644 index 0000000..bcea2a2 Binary files /dev/null and b/instructions/adding-labels.png differ diff --git a/instructions/assign-to-developer-cropped.png b/instructions/assign-to-developer-cropped.png new file mode 100644 index 0000000..92360d1 Binary files /dev/null and b/instructions/assign-to-developer-cropped.png differ diff --git a/instructions/assign-to-developer.png b/instructions/assign-to-developer.png new file mode 100644 index 0000000..d84905c Binary files /dev/null and b/instructions/assign-to-developer.png differ diff --git a/instructions/clickin-new-issue-cropped.png b/instructions/clickin-new-issue-cropped.png new file mode 100644 index 0000000..43d956c Binary files /dev/null and b/instructions/clickin-new-issue-cropped.png differ diff --git a/instructions/clickin-new-issue.png b/instructions/clickin-new-issue.png new file mode 100644 index 0000000..557fde4 Binary files /dev/null and b/instructions/clickin-new-issue.png differ diff --git a/instructions/finding-issues-page-cropped.png b/instructions/finding-issues-page-cropped.png new file mode 100644 index 0000000..822c197 Binary files /dev/null and b/instructions/finding-issues-page-cropped.png differ diff --git a/instructions/finding-issues-page.png b/instructions/finding-issues-page.png new file mode 100644 index 0000000..c29f1fa Binary files /dev/null and b/instructions/finding-issues-page.png differ diff --git a/instructions/image-1.png b/instructions/image-1.png new file mode 100644 index 0000000..bacafb0 Binary files /dev/null and b/instructions/image-1.png differ diff --git a/instructions/image-2.png b/instructions/image-2.png new file mode 100644 index 0000000..96497be Binary files /dev/null and b/instructions/image-2.png differ diff --git a/instructions/image-3.png b/instructions/image-3.png new file mode 100644 index 0000000..d84dbaa Binary files /dev/null and b/instructions/image-3.png differ diff --git a/instructions/image-4.png b/instructions/image-4.png new file mode 100644 index 0000000..94f4850 Binary files /dev/null and b/instructions/image-4.png differ diff --git a/instructions/image-5.png b/instructions/image-5.png new file mode 100644 index 0000000..fc5c0e9 Binary files /dev/null and b/instructions/image-5.png differ diff --git a/instructions/image-6.png b/instructions/image-6.png new file mode 100644 index 0000000..72ac55c Binary files /dev/null and b/instructions/image-6.png differ diff --git a/instructions/instr.pdf b/instructions/instr.pdf new file mode 100644 index 0000000..8a6b58e Binary files /dev/null and b/instructions/instr.pdf differ diff --git a/instructions/instr.tex b/instructions/instr.tex new file mode 100644 index 0000000..bc7c28d --- /dev/null +++ b/instructions/instr.tex @@ -0,0 +1,160 @@ +\documentclass[11pt]{article} + +\usepackage{graphicx} + +\oddsidemargin0cm +\topmargin-3cm +\textwidth16.0cm +\textheight24.5cm + +\newcommand{\step}[2] {\vspace{.25in} \hrule\vspace{0.5em} + \noindent{\bf Step #1: #2} \vspace{0.5em} + \hrule \vspace{.10in}} + +\begin{document} +\thispagestyle{empty} + +\noindent Aaron Gutierrez \& Mitchell Plamann\hfill{15-221}\\ +amgutier@andrew.cmu.edu \& mplamann@andrew.cmu.edu \hfill{Spring 2015}\\ +Section A \hfill{Team 9} + +\vspace{\fill} +\begin{center} +Writing Assignment 3 +Instructions + +\today +\end{center} +\vspace{\fill} + +\newpage + +\pagenumbering{arabic} +\begin{center} +{\Huge Creating and Closing GitHub Issues} +\end{center} +\section{Overview} +GitHub provides a great tool for multi-user collaboration on software projects. +On top of the version control features, GitHub offers sophisticated issue +tracking integrated right in with all of your repositories. Tracking issues +makes it easy to keep track of bugs, new feature ideas, and feedback from +testers, all of which help keep your project organized. In the next five +steps, you will learn how to create a new issues, assign an issue to a +contributor, and mark an issue as resolved. + +This tutorial is for GitHub users who know how to create and use repositories, +but are unfamiliar with GitHub's issue tracking features. You need to have an +existing GitHub repository, a web browser, and a git client on your computer. +Once you're done, you'll be able add, manage, and close issues for every project +you have on GitHub. + +\section{Steps} + +\step{1}{Open your repository's Issues page} +{\bf In this step, you will access the Issues page for your repository.} + +\begin{enumerate} +\item Open your GitHub repository in your web browser. +\item Click ``Issues'' (Fig \ref{fig:issues_button}) +\item You should now see the ``Issues'' page, which you will use in Step 2. +\end{enumerate} + +\begin{figure}[h] + \includegraphics[width=\linewidth]{finding-issues-page-cropped.png} + \caption{Opening the Issues page} + \label{fig:issues_button} +\end{figure} + +\pagebreak + +\step{2}{Create an issue} +{\bf In this step, you will create a new issue associated with your repository and +fill in necessary information} + +\begin{enumerate} +\item Click the ``New Issue'' button (Fig \ref{fig:new_issue}) +\item Enter in a title for the issue (1, Fig \ref{fig:issue_info}) +\item Enter in a description for the issue (2, Fig \ref{fig:issue_info}) +\item Click ``Submit new issue'' (3, Fig \ref{fig:issue_info}) +\item Continue to step 3, where you will add a label to your newly-created issue. +\end{enumerate} + +\begin{figure}[h] + \includegraphics[width=\textwidth]{clickin-new-issue-cropped.png} + \caption{Creating a new issue} + \label{fig:new_issue} +\end{figure} + +\begin{figure}[h] + \includegraphics[width=\textwidth]{new-issue-info-cropped.png} + \caption{Entering issue information} + \label{fig:issue_info} +\end{figure} + +\pagebreak + +\step{3}{Assign labels to an issue} +{\bf In this step, you will label your issue, indicating what type of issue it is.} + +\begin{enumerate} +\item Click the ``Labels'' button (1, Fig \ref{fig:labels}) +\item Click each label that applies to your issue (2, Fig \ref{fig:labels}) +\item Click the X button (3, Fig \ref{fig:labels}) +\item In step 4, you will assign this issue to a developer. +\end{enumerate} + +\begin{figure}[h] + \includegraphics[width=\textwidth]{adding-labels-cropped.png} + \caption{Adding labels to an issue} + \label{fig:labels} +\end{figure} + +\pagebreak + +\step{4}{Assign an issue to a developer} +{\bf In this step, you will assign this issue to a developer who will fix the issue.} + +\begin{enumerate} +\item Click the ``Assignee'' button (1, Fig \ref{fig:assign}) +\item Click the name of the developer who will fix the issue (2, Fig \ref{fig:assign}) +\item At this point, the issue has been assigned to the deveoper. + Once the developer has fixed the issue, proceed to step 5 to mark the issue as resolved. +\end{enumerate} + +\begin{figure}[h] + \includegraphics[width=\textwidth]{assign-to-developer-cropped.png} + \caption{Assigning an issue to a developer} + \label{fig:assign} +\end{figure} + +\pagebreak + +\step{5}{Marking an issue as resolved} +{\bf In this step, you will mark the issue as resolved, + indicating that the developer assigned to the issue has fixed it.} + +\begin{enumerate} +\item On the issue web page, you can see the issue number. + For our example, it is \#3 (Fig \ref{fig:issue_number}). +\item Using your git client on your computer, make a commit as you normally + would including the changes that fix the issue. In the commit message, + include the text ``Resolves \#{\it N}'', replacing {\it N} with your issue number. In + the example issue, the commit message would be ``Resolves \#3''. +\item GitHub detects this commit and marks the issue as closed (Fig \ref{fig:resolved}). + At this point, you have successfully created a GitHub issue, fixed the problem in the repository, + and marked the issue as resolved. +\end{enumerate} + +\begin{figure}[h] + \includegraphics[width=\textwidth]{issue-number-cropped.png} + \caption{Finding the issue number} + \label{fig:issue_number} +\end{figure} + +\begin{figure}[h] + \includegraphics[width=\textwidth]{issue-resolved-cropped.png} + \caption{The issue has been resolved} + \label{fig:resolved} +\end{figure} + +\end{document} diff --git a/instructions/issue-has-been-assigned-cropped.png b/instructions/issue-has-been-assigned-cropped.png new file mode 100644 index 0000000..9c5a211 Binary files /dev/null and b/instructions/issue-has-been-assigned-cropped.png differ diff --git a/instructions/issue-has-been-assigned.png b/instructions/issue-has-been-assigned.png new file mode 100644 index 0000000..5966fd1 Binary files /dev/null and b/instructions/issue-has-been-assigned.png differ diff --git a/instructions/issue-number-cropped.png b/instructions/issue-number-cropped.png new file mode 100644 index 0000000..b934c8d Binary files /dev/null and b/instructions/issue-number-cropped.png differ diff --git a/instructions/issue-resolved-cropped.png b/instructions/issue-resolved-cropped.png new file mode 100644 index 0000000..07fc407 Binary files /dev/null and b/instructions/issue-resolved-cropped.png differ diff --git a/instructions/issue-resolved.png b/instructions/issue-resolved.png new file mode 100644 index 0000000..6d9b6cb Binary files /dev/null and b/instructions/issue-resolved.png differ diff --git a/instructions/label-has-been-added-cropped.png b/instructions/label-has-been-added-cropped.png new file mode 100644 index 0000000..588503b Binary files /dev/null and b/instructions/label-has-been-added-cropped.png differ diff --git a/instructions/label-has-been-added.png b/instructions/label-has-been-added.png new file mode 100644 index 0000000..a4fab5b Binary files /dev/null and b/instructions/label-has-been-added.png differ diff --git a/instructions/new-issue-info-cropped.png b/instructions/new-issue-info-cropped.png new file mode 100644 index 0000000..3611c0c Binary files /dev/null and b/instructions/new-issue-info-cropped.png differ diff --git a/instructions/new-issue-info.png b/instructions/new-issue-info.png new file mode 100644 index 0000000..034a2e6 Binary files /dev/null and b/instructions/new-issue-info.png differ diff --git a/public/site.css b/public/site.css index ca9fef1..72d0847 100644 --- a/public/site.css +++ b/public/site.css @@ -28,5 +28,5 @@ nav { } .btm-btn { - margin-top: 4px; + margin-bottom: 4px; } diff --git a/src/byte-stream.js b/src/byte-stream.js index fbf989e..9cb0f50 100755 --- a/src/byte-stream.js +++ b/src/byte-stream.js @@ -24,7 +24,7 @@ ByteStream.prototype.get_u4 = function() { ByteStream.prototype.get_i4 = function() { var unsigned_val = this.get_u4(); var sign_mult = (unsigned_val & 0x80000000) ? -1 : 1; - return (unsigned_val & 0x7FFFFFFF) * sign_mult; + return (unsigned_val & 0x7FFFFFFF) + (unsigned_val & 0x80000000); } ByteStream.prototype.get_bytes = function(n) { diff --git a/src/bytecode-parser.js b/src/bytecode-parser.js index 35c82de..891a1af 100644 --- a/src/bytecode-parser.js +++ b/src/bytecode-parser.js @@ -72,10 +72,11 @@ var Bc0File = function (filename) { for (var i = 0; i < this.string_count; i++) { var c = stream.get_u1(); if (c == 0) { - this.string_pool.push(current_string); - current_string = ""; + // this.string_pool.push(current_string); + // current_string = ""; + this.string_pool.push(0); } else { - current_string += String.fromCharCode(c); + this.string_pool.push(String.fromCharCode(c)); } } @@ -93,6 +94,15 @@ var Bc0File = function (filename) { } } +Bc0File.prototype.string_from_index = function (i) { + var result = ""; + while (this.string_pool[i] !== 0 && i < this.string_pool.length) { + result += this.string_pool[i]; + i++; + } + return result; +} + function parse(filename) { return new Bc0File(filename); } diff --git a/src/c0vm.js b/src/c0vm.js index bf8170e..2c0696f 100755 --- a/src/c0vm.js +++ b/src/c0vm.js @@ -16,6 +16,13 @@ function c0_memory_error(val) { throw ("c0 memory error: " + val); } +function num_to_i32(num) { + log("num is 0x" + num.toString(16)); + log("num & 0x7FFFFFFF is " + (num & 0x7FFFFFFF)); + log("neg factor is " + ( (num & 0x80000000))); + return (num & 0x7FFFFFFF) + ((num & 0x80000000)); +} + function i32_to_array(i32) { return [(i32 & 0xFF), ((i32 >> 8) & 0xFF), @@ -154,19 +161,20 @@ ProgramState.prototype.step = function() { var y = this.pop(); var x = this.pop(); log("Adding " + x + " and " + y); - this.push((x+y) % 0x100000000); + this.push(num_to_i32(x+y)); break; case op.ISUB: this.frame.pc++; var y = this.pop(); var x = this.pop(); - this.push((x-y) % 0x100000000); + log("Subtracting " + x + " and " + y); + this.push(num_to_i32(x-y)); break; case op.IMUL: this.frame.pc++; var y = this.pop(); var x = this.pop(); - this.push((x*y) % 0x100000000); + this.push(num_to_i32(x*y)); break; case op.IDIV: this.frame.pc++; @@ -231,7 +239,9 @@ ProgramState.prototype.step = function() { case op.VSTORE: this.frame.pc += 2; var index = this.frame.program[this.frame.pc-1]; - this.frame.variables[index] = this.pop(); + var val = this.pop(); + this.frame.variables[index] = val; + log("Set variable " + index + " to value " + val); break; case op.ACONST_NULL: this.frame.pc++; @@ -251,7 +261,7 @@ ProgramState.prototype.step = function() { var c2 = this.frame.program[this.frame.pc-1]; var index = (c1 * 0x1000) + c2; - this.push(this.file.string_pool[index]); + this.push(this.file.string_from_index(index)); break; // Control flow @@ -330,6 +340,8 @@ ProgramState.prototype.step = function() { }; console.log("Unknown native function index " + f.function_table_index); } + log("Calling native function with index " + index + " with arguments " + + arg_array); this.push(native_function(arg_array)); break; @@ -385,7 +397,7 @@ ProgramState.prototype.step = function() { var array_length = this.heap[index]; var elt_size = this.heap[index+1]; if (elt_index >= array_length) c0_memory_error("Array index out of bounds."); - this.push(this.heap[index + 2 + elt_size*elt_index]); + this.push(index + 2 + (elt_size*elt_index)); this.frame.pc++; break; @@ -457,6 +469,8 @@ function execute(file, callbacks, v) { var state = new ProgramState(file, callbacks); + if (verbose) log(file); + log("Beginning execution"); while (true) { @@ -469,7 +483,7 @@ function execute(file, callbacks, v) { console.log(" Stack: " + state.frame.stack); console.log(" PC: " + state.frame.pc); console.log(" Vars: " + state.frame.variables); - console.log(" Code: " + state.frame.program); + // console.log(" Code: " + state.frame.program); console.log(" Heap: " + state.heap); } diff --git a/test/arrays.c0.bc0 b/test/arrays.c0.bc0 index 380b6e0..9dd5a59 100644 --- a/test/arrays.c0.bc0 +++ b/test/arrays.c0.bc0 @@ -48,5 +48,5 @@ B0 # return # 00 01 # native count # native pool -00 01 00 09 # printint +00 01 00 10 # printint diff --git a/test/tests.js b/test/tests.js index c77ee49..f15edaa 100644 --- a/test/tests.js +++ b/test/tests.js @@ -7,14 +7,17 @@ var printout = ""; callbacks[c0ffi.NATIVE_PRINT] = function(args) { printout += args[0]; + return 0; } callbacks[c0ffi.NATIVE_PRINTINT] = function(args) { printout += args[0]; + return 0; } callbacks[c0ffi.NATIVE_PRINTLN] = function(args) { printout += (args[0] + "\n"); + return 0; } function doTest(filename, expected_result) { @@ -57,11 +60,20 @@ exports.testDSQUARED = doTest("dsquared.c0.bc0", 17068); exports.testArrays = function(test) { test.throws(function () { - c0vm.execute(parser.parse("arrays.c0.bc0"), callbacks, true) + c0vm.execute(parser.parse("arrays.c0.bc0"), callbacks, false) }); test.done(); } +exports.testMoreArray = function(test) { + printout = ""; + var result = c0vm.execute(parser.parse("moreArrays.c0.bc0"), callbacks, false); + test.ok(printout == "2312", + "moreArrays.c0.bc0 - Did not print to screen correctly, result was " + + printout); + test.done(); +} + exports.testStructs = function(test) { printout = ""; var result = c0vm.execute(parser.parse("structs.c0.bc0"), callbacks, false); @@ -71,3 +83,18 @@ exports.testStructs = function(test) { test.done(); } +exports.testAbort = function(test) { + test.throws(function () { + c0vm.execute(parser.parse("abort.c0.bc0"), callbacks, false); + }); + test.done(); +} + +exports.testArith = function(test) { + printout = ""; + var result = c0vm.execute(parser.parse("arith.c0.bc0"), callbacks, false); + test.ok(printout == "-2147483648 2147483647 -375 -2147483648 -9 -1 12 \n-12 12 Modulus testing 11-1 5 1 Testing constants -251 Testing inequalities \ny1 y2 y3 n4 n5 n6 y7 Testing bitwise operators \n992000 1045310 53250 -12083 Testing bit shifting\n-2147483648 736 0 588088 -31 -19 \n0\n", + "arith.c0.bc0 - Did not print to screen correctly, result was " + + printout); + test.done(); +} diff --git a/views/index.jade b/views/index.jade index df0530b..f8bf900 100644 --- a/views/index.jade +++ b/views/index.jade @@ -15,9 +15,9 @@ block body form .form-group label(for="inputCode") Code + button(onclick="compile()" type="button").btn.btn-default.btm-btn.pull-right Compile #codearea textarea.code.formControl.sh_c(rows="12" id="inputCode") - button(onclick="compile()" type="button").btn.btn-default.btm-btn.pull-right Compile .col-md-6 p.lbl.