Compare commits
24 Commits
shyam_ragh
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 46af7125da | |||
| 1c68deb03e | |||
| 6f57b3eb7c | |||
| b527218cd3 | |||
| 0e1775fcf3 | |||
| 9f4ae3633d | |||
| 0e04b3f27b | |||
| 63640338bb | |||
| 6661155c32 | |||
| 0542e022bd | |||
| e24ffd6854 | |||
| fbf975b4ec | |||
| 3aad88b19d | |||
| eb1f48ad9c | |||
| 10f5a43a17 | |||
| 609b6e17d4 | |||
| 81a08cb9f8 | |||
| f4b3c06f79 | |||
| 88b006cbcc | |||
| ddf1d00f1b | |||
| 739005289e | |||
|
|
349fd6ff78 | ||
|
|
6138821c3a | ||
|
|
d39df5314d |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -38,3 +38,6 @@ npm-debug.log
|
||||
|
||||
#vim swap files
|
||||
*.swp
|
||||
|
||||
#WHY DO YOU INCLUDE THESE SHYAM?
|
||||
*.project.vim
|
||||
|
||||
7
final/Makefile
Normal file
7
final/Makefile
Normal file
@@ -0,0 +1,7 @@
|
||||
all: final final
|
||||
|
||||
letter:
|
||||
pdflatex letter.tex
|
||||
|
||||
final:
|
||||
pdflatex final.tex && pdflatex final.tex
|
||||
BIN
final/final.pdf
Normal file
BIN
final/final.pdf
Normal file
Binary file not shown.
343
final/final.tex
Executable file
343
final/final.tex
Executable file
@@ -0,0 +1,343 @@
|
||||
\documentclass[11pt]{article}
|
||||
|
||||
\usepackage{setspace}
|
||||
\usepackage[margin=1.75in]{geometry}
|
||||
|
||||
% Make table of contents look better
|
||||
\usepackage{tabularx}
|
||||
\usepackage{tocloft}
|
||||
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
|
||||
|
||||
\usepackage{graphicx}
|
||||
\usepackage{pdfpages}
|
||||
\usepackage{hyperref}
|
||||
|
||||
% \usepackage[ngerman]{babel}
|
||||
% \usepackage[T1]{fontenc}
|
||||
% \usepackage[ansinew]{inputenc}
|
||||
% \usepackage{lmodern}
|
||||
|
||||
% Times New Roman font
|
||||
\usepackage{txfonts}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\setlength{\parindent}{2em}
|
||||
|
||||
\includepdf[pages={1}]{letter.pdf}
|
||||
|
||||
\begin{titlepage}
|
||||
\clearpage
|
||||
\thispagestyle{empty}
|
||||
|
||||
\begin{center}
|
||||
{\Huge Final Report}\\
|
||||
\vspace{10 mm}
|
||||
{\Huge {\tt c0db}\\[.4em]
|
||||
The {\tt C0} Debugger}\\
|
||||
\vspace{10 mm}
|
||||
|
||||
Submitted to\\
|
||||
Mr. Thomas M. Keating\\
|
||||
Assistant Teaching Professor\\
|
||||
School of Computer Science\\
|
||||
Carnegie Mellon University\\
|
||||
Pittsbugh, PA 15289
|
||||
|
||||
\vspace{10 mm}
|
||||
|
||||
Prepared by:\\
|
||||
{\bf Aaron Gutierrez}\\
|
||||
{\bf Shyam Raghavan}\\
|
||||
Mitchell Plamann\\
|
||||
Suhaas Reddy
|
||||
|
||||
\vspace{10 mm}
|
||||
|
||||
School of Computer Science\\
|
||||
Carnegie Mellon University\\
|
||||
\today
|
||||
|
||||
\vspace{10 mm}
|
||||
|
||||
{\bf Abstract}
|
||||
\end{center}
|
||||
\par
|
||||
Finding problems in code is a difficult and time consuming task, one especially
|
||||
difficult for programmers learning a new language. To help students more quickly
|
||||
find bugs and understand how their programs run, we created an online debugger
|
||||
for the {\tt C0} programming language. The {\tt C0} debugger, {\tt c0db},
|
||||
enables users to run programs in their browser and break apart the execution
|
||||
when they don't run correctly.
|
||||
\end{titlepage}
|
||||
|
||||
\pagenumbering{roman}
|
||||
\tableofcontents
|
||||
\newpage
|
||||
|
||||
\pagenumbering{arabic}
|
||||
|
||||
\section{Introduction}
|
||||
We discuss the problems we hoped to resolve, give an overview of the project,
|
||||
and show how the project solves the problems outlined. We also analyze the
|
||||
effectiveness of the literature reviewed and the final accomplishments compared
|
||||
to our original goals.
|
||||
\subsection{Background}
|
||||
One of Carnegie Mellon University's most widely attended class is 15-122,
|
||||
Principles of Imperative Computation. 15-122 contains a capstone assignment
|
||||
called the {\tt C0} Virtual Machine, which involves implementing a program that
|
||||
allows the user to run arbitrary code in the language in which 15-122 is
|
||||
taught, {\tt C0}. The implementation of the virtual machine (C0VM) is not an
|
||||
easy task - it involves higher level thinking and a deep understanding of the
|
||||
abstractions associated with running arbitrary code.
|
||||
\par
|
||||
Because it is difficult, the {\tt c0db} ({\tt C0} Debugger) hoped to improve
|
||||
the learning process by making visualization and interaction with a working
|
||||
implementation of the C0VM more accessible to 15-122 students. This involved
|
||||
creating a working Javascript version of the C0VM, implementing visualizers for
|
||||
relevant parts of the assignment, and developing the interface for
|
||||
student-based interaction with the application.
|
||||
\par
|
||||
In order to begin learning using {\tt C0}, students must
|
||||
become familiar with the Unix operating system environment. This overhead
|
||||
causes a delay in the learning of students, and increases the barrier to entry
|
||||
for many people.
|
||||
\subsection{Project Overview}
|
||||
By implementing the {\tt c0db}, we hoped to benefit students in 15-122 by
|
||||
helping them create correct programs. The {\tt c0db} will enable students to
|
||||
understand how their programs execute and find where problems originate more
|
||||
easily than with existing tools. In addition to debugging, students will have a
|
||||
more familiar understanding of the underlying computational model represented
|
||||
in the debugger through the use of our application.
|
||||
\par
|
||||
The {\tt C0} Debugger will also enable students to test simple programs with
|
||||
little setup, using only a web browser. They will no longer have to set up and
|
||||
become familiar with a Unix environment before they can program, making {\tt
|
||||
C0} accessible to more people.
|
||||
\par
|
||||
The project manifested itself in what is now \url{http://c0db.herokuapp.com}.
|
||||
The application provides an input field for students to enter {\tt C0} code,
|
||||
outputs intermediate bytecode, and has the ability to run said bytecode. The
|
||||
application also has functionality that allows for breakpoints, stepping
|
||||
through code, and continuing the code from the current breakpoint. With this
|
||||
application, we were able to effectively meet the goals of improving coding
|
||||
accessibility, creating familiarity with the underlying computational model of
|
||||
computers, and being able to more easily debug programs. We were unable to
|
||||
effectively meet the goals of visualization and interactivity with respect to
|
||||
the debugger and {\tt C0}.
|
||||
\subsection{Analysis of Literature Review}
|
||||
There was very little relevant literature to the subject at hand. The
|
||||
documentation found involved implementing Javascript virtual machines and
|
||||
debuggers, and while this was of some use (detailed below), the disconnect
|
||||
between implementing a Javascript virtual machine and a {\tt C0} virtual
|
||||
machine was apparent. This was also felt in the literature associated with
|
||||
processing user-input code.
|
||||
\par
|
||||
The literature that was discovered during development became very helpful as
|
||||
the project evolved. Of particular importance was unit testing and the original
|
||||
handout given to students implementing the virtual machine in C.
|
||||
\par
|
||||
The greatest difficulties faced by the lack of information pertaining to
|
||||
creating a virtual machine for a language that was not Javascript involved
|
||||
developing the framework to parse through the intermediate bytecode given
|
||||
by the compiler of {\tt C0}. The information about building an in-browser
|
||||
Javascript VM and debugger\footnote{http://amasad.me/2014/01/06/building-an-in-browser-javascript-vm-and-debugger-using-generators/}
|
||||
was a particular example of this. We hoped to design our debugger's architecture
|
||||
based on this virtual machine's architecture. The literature mentioned being
|
||||
designed in two parts. Specifically, the application was designed around a
|
||||
virtual machine and a debugger. Unfortunately, because of the way {\tt C0} is
|
||||
designed and the way the bytecode intermediate is evaluated, we found it very
|
||||
difficult to follow this modularized approach, and had to combine the two.
|
||||
\par
|
||||
The second piece of literature we believed would be helpful when proposing this
|
||||
project\footnote{http://www.aosabook.org/en/pjs.html} was not helpful at all.
|
||||
While it did give us issues to consider such as the lack of threading and the
|
||||
presence of asynchronous calls in Javascript, we felt as though it did not
|
||||
provide any information about the transferral of information from the webpage
|
||||
to the back-end virtual machine and debugger. This was what we hoped we would
|
||||
be able to use from it, and while it was helpful in giving ideas about possible
|
||||
approaches to this problem, it did not give any insight into the development of
|
||||
a script to compile code and receive intermediate bytecode (the solution that
|
||||
we eventually employed).
|
||||
\par
|
||||
The other pieces of literature we reviewed (the Node.js
|
||||
documentation\footnote{http://nodejs.org/documentation/}, the Nodeunit
|
||||
documentation\footnote{https://github.com/caolan/nodeunit}, and the handout
|
||||
given to students to complete the {\tt C0} virtual
|
||||
machine\footnote{https://www.cs.cmu.edu/~rjsimmon/15122-f14/prog/c0vm-writeup.pdf})
|
||||
were all very helpful. The handout helped us design an architecture that
|
||||
allowed for easy implementation in the browser and in Javascript. This
|
||||
architecture was very similar to that of the architecture that students are
|
||||
given when first completing the virtual machine in C. The Node.js documentation
|
||||
and Nodeunit documentation proved very useful when developing the application
|
||||
and creating unit tests to test the framework and the application. The
|
||||
documentation provided easy answers to questions that arose with implementation.
|
||||
\subsection{Successes}
|
||||
The final product was successful at completing three of the four goals we set
|
||||
out to accomplish. We were successful at improving accessibility of coding and
|
||||
programming to students and beginners. The application allows for a simple
|
||||
interface to enter code, compile it, and run it. We were successful at
|
||||
creating familiarity with the underlying computation model represented in a
|
||||
virtual machine. The application gives information about the current state
|
||||
of the model at each point in execution, and allows the user to examine the
|
||||
internals of the computational model. Finally, we were also successful at
|
||||
creating a tool that allows for debugging {\tt C0} code. This is represented
|
||||
in the ability of the application to step through the code.
|
||||
\par
|
||||
We were not successful at developing a visualization component to help
|
||||
beginners learn about the computational model. This is something we hope to
|
||||
be able to do and, in the future, we hope will help the students of 15-122
|
||||
learn more about computer science.
|
||||
|
||||
\section{Approach}
|
||||
In this section, we outline the various phases of our development cycle. We
|
||||
also make note of the technologies used to implement the application.
|
||||
|
||||
\begin{figure}[h]
|
||||
\includegraphics[width=\linewidth]{new-gantt}
|
||||
\caption{Revised project Gantt chart}
|
||||
\label{gantt}
|
||||
\end{figure}
|
||||
\subsection{Phase 1}
|
||||
Phase 1 was centered around the design of the application, and didn't involve
|
||||
very much actual programming. This phase was completed a bit later than hoped.
|
||||
However, due to its short nature, it did not put us far behind our ideal
|
||||
schedule. During Phase 1, we realized that the best option for architecture
|
||||
of our application was to structure it similarly to the structure that students
|
||||
in 15-122 use and that is provided by the course staff.
|
||||
\par
|
||||
While the infrastructure could have been designed in a more efficient way, we
|
||||
feel as though Phase 1 was effective at creating a base layer from which to
|
||||
implement both the front-end and the back-end of the application. At the end
|
||||
of Phase 1, we had a framework upon which the successful web application was
|
||||
developed, and we were able to coordinate and delegate tasks between team
|
||||
members.
|
||||
\subsection{Phase 2}
|
||||
Phase 2 was focused on the back-end of the application. Phase 2 involved
|
||||
actually implementing the framework described in Phase 1, developing the script
|
||||
to transform uncompiled {\tt C0} code into bytecode intermediate, developing
|
||||
the virtual machine in which the bytecode was executed, implementing a
|
||||
state-based breakpoint system that allows for inserting breakpoints into the
|
||||
code, and implementing step-based functionality that allows for users to step
|
||||
through the running code.
|
||||
\par
|
||||
In this phase, we used the Node.js framework to implement the application. This
|
||||
framework is a commonly-used web application framework in Javascript that is
|
||||
used to easily get a running website. We also found Nodeunit, a unit testing
|
||||
framework designed for use with the Node.js framework. Nodeunit allowed us to
|
||||
write over 50 test files to check for correctness and safety of our virtual
|
||||
machine.
|
||||
\par
|
||||
This phase finished on time after the revision of the Gantt chart (\ref{gantt}).
|
||||
There are still some features that we would like to implement before declaring
|
||||
the back-end finished, but these involve going further than the stated goals.
|
||||
The back-end created an effective interface from which the front-end team was
|
||||
able to develop the front-end.
|
||||
\subsection{Phase 3}
|
||||
Phase 3 was focused on the front-end of the application. Phase 3 involved
|
||||
implementing the front-end side of the framework described in Phase 1. This
|
||||
includes implementing the user interface for inputting {\tt C0} code, creating
|
||||
the design and implementing the design for outputting the intermediate
|
||||
bytecode, creating an effective medium of outputting runtime output, and
|
||||
developing an interactive suite of tools for debugging such as adding
|
||||
breakpoints, stepping through code, and viewing the internal computational
|
||||
model.
|
||||
\par
|
||||
In this phase, we used LESS, a CSS preprocessor, as opposed to plain CSS. LESS
|
||||
is a widely used styling language that is compiled into CSS because it is easier
|
||||
to write than CSS. We also used JQuery, a front-end framework that is used to
|
||||
connect elements of the front-end design to back-end Javascript. These were
|
||||
chosen because they allow for fast, correct development, and make it easier
|
||||
to focus on development and design, not rewriting existing code.
|
||||
\par
|
||||
This phase also finished on time after the revision of the Gantt chart
|
||||
(\ref{gantt}). We did not quite finish all features we hoped we would be able
|
||||
to complete originally. The features not completed involved more intuitive
|
||||
interactivity and a better visualization tool for viewing the internals of the
|
||||
computational model. The front-end, however, was successful at developing the
|
||||
front-end such that most desired goals were achieved.
|
||||
\subsection{Phases 4 and 5}
|
||||
Phases 4 and 5 were centered around user testing and revision. These phases
|
||||
are still in process, and will continue to be in process until the tool is
|
||||
developed to the point at which it is used in the 15-122 course curriculum.
|
||||
Phase 4 involved showing the product to the 15-122 course staff and getting
|
||||
opinions from the teaching assistants that would be using the tool in a
|
||||
teaching setting, showing the product to the 15-122 professors, and showing
|
||||
the product to 15-122 students. Each of these groups was given an opportunity
|
||||
to interact with the product, and was asked to provide feedback on usability,
|
||||
learnability, and overall usefulness. Phase 5 involves revising the product
|
||||
based on this feedback. Phase 4 is still in process, and as a result, Phase 5
|
||||
has not begun yet.
|
||||
|
||||
\section{Results}
|
||||
We originally aimed to evaluate our performance against user feedback from both
|
||||
current and past students. However, due to setbacks in the early stages of
|
||||
development we were unable to receive significant use feedback from students.
|
||||
That said, we were able to gather feedback and support from current 15-122
|
||||
course staff.
|
||||
\par
|
||||
In terms of our original vision, {\tt c0db} includes almost every feature we
|
||||
planned to implement. Users can input code and either run the program straight
|
||||
through or step through execution instruction by instruction. The only
|
||||
significant feature that is not currently implemented completely is breakpoints.
|
||||
Implementing breakpoints turned out to be significantly more difficult than we
|
||||
anticipated, and given our limited time frame, we were unable to come up with an
|
||||
adequate solution. We are currently working with Rob Simmons, 15-122 instructor
|
||||
and maintainer for the {\tt C0} language standard, to extend the language to
|
||||
support breakpoints more easily going forward.
|
||||
|
||||
\begin{figure}[h]
|
||||
\includegraphics[width=\linewidth]{new-gantt}
|
||||
\caption{Revised project Gantt chart (copied from above for convenience)}
|
||||
\label{gantt}
|
||||
\end{figure}
|
||||
Relative to our revised Gantt Chart (Figure \ref{gantt}) we hit every milestone
|
||||
on time. Both the front-end and back-end teams completed their tasks by the end
|
||||
of April, at which point we transitioned everyone to user testing, revisions,
|
||||
and polishing. Both teams were able to recover from the lag reported in our
|
||||
progress report to complete {\tt c0db}.
|
||||
|
||||
\section{Discussion}
|
||||
\subsection{Reflection}
|
||||
Our team learned several useful skills while working on this project, ranging
|
||||
from technical tricks to communication insights. For several of us, this project
|
||||
represents the most collaboration on a single code base. We effectively employed
|
||||
the git version control system to manage our code to lesson the work needed to
|
||||
integrate each person's features. Additionally, several members of our team had
|
||||
never worked with node.js or JavaScript extensively before this project.
|
||||
Everyone quickly picked up the new framework and started producing useful
|
||||
output.
|
||||
\par
|
||||
We did face some issues communicating early on, but fortunately we were able to
|
||||
learn from our problems. Communicating strictly online was not sufficient and
|
||||
resulted in a lack of ownership and drive that put us behind schedule early on.
|
||||
We overcame our communication problems by holding brief but regular meetings
|
||||
face to face to cover what has been accomplished and what tasks come next.
|
||||
|
||||
\subsection{Future}
|
||||
{\tt C0db} is most of what we imagined, but not all. Our overall goal, to make a
|
||||
tool useful for 15-122 students, may be realized in the fall, but we have more
|
||||
work to ensure that we present them with the best tool possible. Before the next
|
||||
semester starts we aim to complete the remaining features we originally planned
|
||||
to implement: source-level breakpoints, multi-file support, and a refined
|
||||
interface. If we can implement these three features, {\tt c0db} could see proper
|
||||
adoption by 15-122 in the fall, where it would be used by over 300 students from
|
||||
across Carnegie Mellon. If {\tt c0db} is adopted by 15-122, we would truly have
|
||||
achieved the goal for our project: create a tool to better the CMU community.
|
||||
|
||||
\section{Sources Cited}
|
||||
\begin{enumerate}
|
||||
\item Amjad Masad,
|
||||
``Building an In-Browser JavaScript VM and Debugger Using Generators'',
|
||||
http://amasad.me/2014/01/06/building-an-in-browser-javascript-vm-and-debugger-using-generators/
|
||||
\item Mike Kamermans, ``The Architecture of Open Source Applications (Volume 2)'',
|
||||
http://www.aosabook.org/en/pjs.html
|
||||
\item Joyent, Inc., ``Node.js Documentation'',
|
||||
http://nodejs.org/documentation
|
||||
\item ``Nodeunit documentation'',
|
||||
https://github.com/caolan/nodeunit
|
||||
\item ``c0vm Assignment Handout'',\\
|
||||
https://www.cs.cmu.edu/~rjsimmon/15122-f14/prog/c0vm-writeup.pdf
|
||||
\end{enumerate}
|
||||
|
||||
\end{document}
|
||||
BIN
final/gantt.jpg
Normal file
BIN
final/gantt.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
final/letter.pdf
Executable file
BIN
final/letter.pdf
Executable file
Binary file not shown.
41
final/letter.tex
Executable file
41
final/letter.tex
Executable file
@@ -0,0 +1,41 @@
|
||||
\documentclass[11pt,stdletter,sigleft]{letter}
|
||||
|
||||
\usepackage{setspace}
|
||||
\usepackage[margin=1.75in]{geometry}
|
||||
|
||||
\usepackage{txfonts}
|
||||
|
||||
\signature{Shyam Raghavan}
|
||||
\address{5032 Forbes Ave \\ SMC 2426 \\ Pittsburgh, PA 15289}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\begin{letter}{Mr. Thomas M. Keating \\
|
||||
Assistant Teaching Professor \\
|
||||
School of Computer Science \\
|
||||
Pittsburgh, PA 15289}
|
||||
|
||||
\opening{Dear Mr. Keating:}
|
||||
\vspace{5mm}
|
||||
|
||||
Included with this letter is our team's final report for the browser-based
|
||||
debugger for the {\tt C0} language called {\tt c0db}, the {\tt C0} Debugger.
|
||||
The purpose of the report is to update you on our progress and to explain and
|
||||
discuss our results.
|
||||
|
||||
The report describes the problem addressed by our project, our approach to
|
||||
solve it, the results we were able to achieve, our challenges and struggles,
|
||||
the lessons we learned throughout the progress we made, and some
|
||||
recommendations on how we or another group can continue to build on our
|
||||
existing platform.
|
||||
|
||||
If you have any further questions or comments, please contact us at one of the
|
||||
following emails: shyamsur@andrew.cmu.edu, amgutier@andrew.cmu.edu.\\
|
||||
|
||||
Sincerely,\\[4em]
|
||||
Shyam Raghavan
|
||||
|
||||
\encl{project final paper for {\tt c0db}}
|
||||
|
||||
\end{letter}
|
||||
\end{document}
|
||||
BIN
final/new-gantt.png
Normal file
BIN
final/new-gantt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
@@ -5,24 +5,22 @@ the following are the most important ones.
|
||||
\item Nodeunit documentation \\
|
||||
https://github.com/caolan/nodeunit \\
|
||||
% It might be better to put the URLs in the "References" section and add a [\ref{}] here
|
||||
We are using nodeunit to test our virtual machine.
|
||||
Since the c0 bytecode has many different opcodes that it uses, it is very easy
|
||||
for mistakes in the virtual machine to go unnoticed.
|
||||
To prevent this, we are using the nodeunit library to write unit tests for our
|
||||
code.
|
||||
This has already helped us to find and solve multiple bugs in the VM, and having
|
||||
these unit tests will make sure that we can solve any bugs that occur as the
|
||||
result of future changes in the code.
|
||||
We are using nodeunit to test our virtual machine. Since the c0 bytecode has
|
||||
many different opcodes that it uses, it is very easy for mistakes in the virtual
|
||||
machine to go unnoticed. To prevent this, we are using the nodeunit library to
|
||||
write unit tests for our code. This has already helped us to find and solve
|
||||
multiple bugs in the VM, and having these unit tests will make sure that we can
|
||||
solve any bugs that occur as the result of future changes in the code.
|
||||
\item C0vm Assignment Handout \\
|
||||
https://www.cs.cmu.edu/~rjsimmon/15122-f14/prog/c0vm-writeup.pdf \\
|
||||
This document details how each opcode in the c0 bytecode language works,
|
||||
as well as other important implementation details for the c0 virtual machine.
|
||||
It has been an important reference while developing a JavaScript version
|
||||
of the c0 virtual machine.
|
||||
https://www.cs.cmu.edu/~rjsimmon/15122-f14/prog/c0vm-writeup.pdf \\ This
|
||||
document details how each opcode in the c0 bytecode language works, as well as
|
||||
other important implementation details for the c0 virtual machine. It has been
|
||||
an important reference while developing a JavaScript version of the c0 virtual
|
||||
machine.
|
||||
\end{itemize}
|
||||
So far, the most important thing we have learned is that good unit tests are
|
||||
vital for developing this sort of project. Without unit tests that verify
|
||||
each opcode used by the virtual machine, many bugs would have gone unnoticed,
|
||||
causing problems later down the line. If we only found these bugs by using
|
||||
the frontend, they would have been much harder to debug, as there would have
|
||||
been much more code to work through.
|
||||
vital for developing this sort of project. Without unit tests that verify each
|
||||
opcode used by the virtual machine, many bugs would have gone unnoticed, causing
|
||||
problems later down the line. If we only found these bugs by using the frontend,
|
||||
they would have been much harder to debug, as there would have been much more
|
||||
code to work through.
|
||||
|
||||
1
progress_report/lit_review_aux
Normal file
1
progress_report/lit_review_aux
Normal file
@@ -0,0 +1 @@
|
||||
\relax
|
||||
@@ -1,23 +0,0 @@
|
||||
" ATP project vim script: Tue Apr 14, 2015 at 08:36 PM -0400.
|
||||
|
||||
let b:atp_MainFile = 'progress.tex'
|
||||
let g:atp_mapNn = 0
|
||||
let b:atp_autex = 1
|
||||
let b:atp_TexCompiler = 'pdftex'
|
||||
let b:atp_TexOptions = '-synctex=1'
|
||||
let b:atp_TexFlavor = 'plaintex'
|
||||
let b:atp_auruns = '1'
|
||||
let b:atp_ReloadOnError = '1'
|
||||
let b:atp_OutDir = '/Users/shyam/Dropbox/cdb/progress_report'
|
||||
let b:atp_OpenViewer = '1'
|
||||
let b:atp_XpdfServer = 'progress'
|
||||
let b:atp_Viewer = 'okular'
|
||||
let b:TreeOfFiles = {}
|
||||
let b:ListOfFiles = []
|
||||
let b:TypeDict = {}
|
||||
let b:LevelDict = {}
|
||||
let b:atp_BibCompiler = 'bibtex'
|
||||
let b:atp_StarEnvDefault = ''
|
||||
let b:atp_StarMathEnvDefault = ''
|
||||
let b:atp_updatetime_insert = 4000
|
||||
let b:atp_updatetime_normal = 2000
|
||||
@@ -1,30 +0,0 @@
|
||||
" ATP project vim script: Tue Apr 14, 2015 at 02:37 PM -0400.
|
||||
|
||||
let b:atp_MainFile = 'progress_report.tex'
|
||||
let g:atp_mapNn = 0
|
||||
let b:atp_autex = 1
|
||||
let b:atp_TexCompiler = 'pdftex'
|
||||
let b:atp_TexOptions = '-synctex=1'
|
||||
<<<<<<< HEAD
|
||||
let b:atp_TexFlavor = 'tex'
|
||||
=======
|
||||
let b:atp_TexFlavor = 'plaintex'
|
||||
>>>>>>> ff581d8a8ce9932bf474596368f94b00770b98d9
|
||||
let b:atp_auruns = '1'
|
||||
let b:atp_ReloadOnError = '1'
|
||||
let b:atp_OutDir = '/Users/shyam/Dropbox/cdb/progress_report'
|
||||
let b:atp_OpenViewer = '1'
|
||||
let b:atp_XpdfServer = 'progress_report'
|
||||
let b:atp_Viewer = 'okular'
|
||||
let b:TreeOfFiles = {}
|
||||
let b:ListOfFiles = []
|
||||
let b:TypeDict = {}
|
||||
let b:LevelDict = {}
|
||||
let b:atp_BibCompiler = 'bibtex'
|
||||
let b:atp_StarEnvDefault = ''
|
||||
let b:atp_StarMathEnvDefault = ''
|
||||
let b:atp_updatetime_insert = 4000
|
||||
let b:atp_updatetime_normal = 2000
|
||||
let b:atp_LocalCommands = []
|
||||
let b:atp_LocalEnvironments = []
|
||||
let b:atp_LocalColors = []
|
||||
@@ -1,7 +1,22 @@
|
||||
Approach
|
||||
The approach section contains our methodology, how we plan to implement the project, and our project schedule, the timeline we plan to adhere to. The methodology outlines the specific tools we will use to complete the project in a timely manner whereas the schedule outlines the deadlines by which we hope to have certain tasks completed.
|
||||
The approach section contains our methodology, how we plan to
|
||||
implement the project, and our project schedule, the timeline we plan to adhere
|
||||
to. The methodology outlines the specific tools we will use to complete the
|
||||
project in a timely manner whereas the schedule outlines the deadlines by which
|
||||
we hope to have certain tasks completed.
|
||||
|
||||
Methodology
|
||||
C$_0$ Cement is a Debugger designed for the CMU teaching language, C$_0$. It will be hosted on <BLANK> with the website itself designed in CSS and HTML, using Node.js to run most of the core functionality. We will first deploy a blank template website after which half of the team wil work on parsing C0 bytecode and the other half will work on creating a meaningful user experience. Once both teams have made reasonable progress, they will combine the two units to complete the basic outline of the project.
|
||||
Project Schedule
|
||||
The project will be separated into five main phases: Basic Website Design, Backend implementation, Frontend Implementation, User Testing, and Revisions. The first phase should take <POSSIBLY CHANGE THIS> less than a week with the next two phases occurring simultaneously and composing the rest of the month's work. User implementation and revisions will then hopefully take up the remainder of the alloted time, with extra time padded in case implementation or revisions are more extensive than we have predicted.
|
||||
C$_0$ Cement is a Debugger designed for the CMU teaching language,
|
||||
C$_0$. It will be hosted on <BLANK> with the website itself designed in CSS and
|
||||
HTML, using Node.js to run most of the core functionality. We will first deploy
|
||||
a blank template website after which half of the team wil work on parsing C0
|
||||
bytecode and the other half will work on creating a meaningful user experience.
|
||||
Once both teams have made reasonable progress, they will combine the two units
|
||||
to complete the basic outline of the project. Project Schedule The project
|
||||
will be separated into five main phases: Basic Website Design, Backend
|
||||
implementation, Frontend Implementation, User Testing, and Revisions. The first
|
||||
phase should take <POSSIBLY CHANGE THIS> less than a week with the next two
|
||||
phases occurring simultaneously and composing the rest of the month's work.
|
||||
User implementation and revisions will then hopefully take up the remainder of
|
||||
the alloted time, with extra time padded in case implementation or revisions
|
||||
are more extensive than we have predicted.
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
" ATP project vim script: Tue Apr 14, 2015 at 02:43 PM -0400.
|
||||
|
||||
let b:atp_MainFile = 'proposal.tex'
|
||||
let g:atp_mapNn = 0
|
||||
let b:atp_autex = 1
|
||||
let b:atp_TexCompiler = 'pdflatex'
|
||||
let b:atp_TexOptions = '-synctex=1'
|
||||
let b:atp_TexFlavor = 'tex'
|
||||
let b:atp_auruns = '1'
|
||||
let b:atp_ReloadOnError = '1'
|
||||
let b:atp_OutDir = '/Users/shyam/Dropbox/cdb/proposal'
|
||||
let b:atp_OpenViewer = '1'
|
||||
let b:atp_XpdfServer = 'proposal'
|
||||
let b:atp_Viewer = 'okular'
|
||||
let b:TreeOfFiles = {}
|
||||
let b:ListOfFiles = []
|
||||
let b:TypeDict = {}
|
||||
let b:LevelDict = {}
|
||||
let b:atp_BibCompiler = 'bibtex'
|
||||
let b:atp_StarEnvDefault = ''
|
||||
let b:atp_StarMathEnvDefault = ''
|
||||
let b:atp_updatetime_insert = 4000
|
||||
let b:atp_updatetime_normal = 2000
|
||||
let b:atp_LocalCommands = []
|
||||
let b:atp_LocalEnvironments = []
|
||||
let b:atp_LocalColors = []
|
||||
28
public/css/site.css
Normal file
28
public/css/site.css
Normal file
@@ -0,0 +1,28 @@
|
||||
.code {
|
||||
font-family: "DejaVu Sans Mono", Consolas, monospace;
|
||||
width: 100%;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
border-color: #ddd;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.brad {
|
||||
font-family: "Courier New", Courier, monospace;
|
||||
font-size: 26pt;
|
||||
color: #166d00;
|
||||
}
|
||||
.brad :hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
nav {
|
||||
background-color: #d8d8d8;
|
||||
}
|
||||
.lbl {
|
||||
font-weight: bold;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.btm-btn {
|
||||
margin-bottom: 4px;
|
||||
margin-top: -10px;
|
||||
}
|
||||
@@ -12,12 +12,10 @@
|
||||
font-family: "Courier New", Courier, monospace;
|
||||
font-size: 26pt;
|
||||
color: #166d00;
|
||||
}
|
||||
.brad:hover {
|
||||
font-family: "Courier New", Courier, monospace;
|
||||
font-size: 26pt;
|
||||
color: #166d00;
|
||||
text-decoration: none;
|
||||
|
||||
:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
nav {
|
||||
@@ -31,5 +29,8 @@ nav {
|
||||
|
||||
.btm-btn {
|
||||
margin-bottom: 4px;
|
||||
margin-top: -14px;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
.no_disp {
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
FILES = c0vm.js bytecode-parser.js byte-stream.js opcodes.js index.js
|
||||
FILES = c0vm.js bytecode-parser.js byte-stream.js opcodes.js c0ffi.js index.js
|
||||
|
||||
all: $(FILES)
|
||||
browserify $(FILES) -o vm.js
|
||||
|
||||
clean:
|
||||
rm -f vm.js
|
||||
|
||||
@@ -90,6 +90,7 @@ var Bc0File = function (filename) {
|
||||
this.function_pool = [];
|
||||
for (var i = 0; i < this.function_count; i++) {
|
||||
this.function_pool.push(new FunctionInfo(stream));
|
||||
this.function_pool[i].function_id = i;
|
||||
}
|
||||
|
||||
this.native_count = stream.get_u2();
|
||||
|
||||
@@ -80,31 +80,87 @@ exports.NATIVE_FILE_READLINE = 68
|
||||
exports.NATIVE_IMAGE_CLONE = 69
|
||||
exports.NATIVE_IMAGE_CREATE = 70
|
||||
exports.NATIVE_IMAGE_DATA = 71
|
||||
exports.NATIVE_IMAGE_DESTROY = 72
|
||||
exports.NATIVE_IMAGE_HEIGHT = 73
|
||||
exports.NATIVE_IMAGE_LOAD = 74
|
||||
exports.NATIVE_IMAGE_SAVE = 75
|
||||
exports.NATIVE_IMAGE_SUBIMAGE = 76
|
||||
exports.NATIVE_IMAGE_WIDTH = 77
|
||||
exports.NATIVE_IMAGE_HEIGHT = 72
|
||||
exports.NATIVE_IMAGE_LOAD = 73
|
||||
exports.NATIVE_IMAGE_SAVE = 74
|
||||
exports.NATIVE_IMAGE_SUBIMAGE = 75
|
||||
exports.NATIVE_IMAGE_WIDTH = 76
|
||||
|
||||
/* parse */
|
||||
exports.NATIVE_PARSE_BOOL = 78
|
||||
exports.NATIVE_PARSE_INT = 79
|
||||
exports.NATIVE_INT_TOKENS = 77
|
||||
exports.NATIVE_NUM_TOKENS = 78
|
||||
exports.NATIVE_PARSE_BOOL = 79
|
||||
exports.NATIVE_PARSE_INT = 80
|
||||
exports.NATIVE_PARSE_INTS = 81
|
||||
exports.NATIVE_PARSE_TOKENS = 82
|
||||
|
||||
/* string */
|
||||
exports.NATIVE_CHAR_CHR = 80
|
||||
exports.NATIVE_CHAR_ORD = 81
|
||||
exports.NATIVE_STRING_CHARAT = 82
|
||||
exports.NATIVE_STRING_COMPARE = 83
|
||||
exports.NATIVE_STRING_EQUAL = 84
|
||||
exports.NATIVE_STRING_FROM_CHARARRAY = 85
|
||||
exports.NATIVE_STRING_FROMBOOL = 86
|
||||
exports.NATIVE_STRING_FROMCHAR = 87
|
||||
exports.NATIVE_STRING_FROMINT = 88
|
||||
exports.NATIVE_STRING_JOIN = 89
|
||||
exports.NATIVE_STRING_LENGTH = 90
|
||||
exports.NATIVE_STRING_SUB = 91
|
||||
exports.NATIVE_STRING_TERMINATED = 92
|
||||
exports.NATIVE_STRING_TO_CHARARRAY = 93
|
||||
exports.NATIVE_STRING_TOLOWER = 94
|
||||
exports.NATIVE_CHAR_CHR = 83
|
||||
exports.NATIVE_CHAR_ORD = 84
|
||||
exports.NATIVE_STRING_CHARAT = 85
|
||||
exports.NATIVE_STRING_COMPARE = 86
|
||||
exports.NATIVE_STRING_EQUAL = 87
|
||||
exports.NATIVE_STRING_FROM_CHARARRAY = 88
|
||||
exports.NATIVE_STRING_FROMBOOL = 89
|
||||
exports.NATIVE_STRING_FROMCHAR = 90
|
||||
exports.NATIVE_STRING_FROMINT = 91
|
||||
exports.NATIVE_STRING_JOIN = 92
|
||||
exports.NATIVE_STRING_LENGTH = 93
|
||||
exports.NATIVE_STRING_SUB = 94
|
||||
exports.NATIVE_STRING_TERMINATED = 95
|
||||
exports.NATIVE_STRING_TO_CHARARRAY = 96
|
||||
exports.NATIVE_STRING_TOLOWER = 97
|
||||
|
||||
callbacks = {};
|
||||
callbacks[exports.NATIVE_STRING_LENGTH] =
|
||||
function(args) {
|
||||
return args[0].length;
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_STRING_TO_CHARARRAY] =
|
||||
function(args, vm) {
|
||||
var address = vm.heap.length;
|
||||
vm.heap.push(args[0].length+1);
|
||||
vm.heap.push(1);
|
||||
for (var i = 0; i < args[0].length; i++) {
|
||||
vm.heap.push(args[0][i]);
|
||||
}
|
||||
vm.heap.push(0);
|
||||
return address;
|
||||
};
|
||||
|
||||
|
||||
callbacks[exports.NATIVE_STRING_FROM_CHARARRAY] =
|
||||
function(args, vm) {
|
||||
var i = args[0] + 2;
|
||||
var result = "";
|
||||
while (vm.heap[i] !== 0) {
|
||||
result += vm.heap[i];
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_CHAR_CHR] =
|
||||
function(args) {
|
||||
return String.fromCharCode(args[0]);
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_CHAR_ORD] =
|
||||
function(args) {
|
||||
if (typeof args[0] == "string")
|
||||
return args[0].charCodeAt(0);
|
||||
return args[0];
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_STRING_COMPARE] = function(args) {
|
||||
if (args[0] < args[1]) return -1;
|
||||
if (args[0] > args[1]) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
callbacks[exports.NATIVE_STRING_EQUAL] = function(args) {
|
||||
return args[0] === args[1];
|
||||
}
|
||||
|
||||
exports.default_callbacks = callbacks;
|
||||
|
||||
@@ -3,9 +3,8 @@ op = require("./opcodes");
|
||||
var INT_MIN = 0x80000000;
|
||||
var INT_MAX = 0x7FFFFFFF;
|
||||
|
||||
var verbose = false;
|
||||
function log(message) {
|
||||
if (verbose) console.log(message);
|
||||
if (verbose) $("#internals").val($("#internals").val() + "\n" + message);
|
||||
}
|
||||
|
||||
function c0_assertion_failure(val) {
|
||||
@@ -42,6 +41,7 @@ var StackFrame = function(file, f) {
|
||||
this.stack = [];
|
||||
this.pc = 0;
|
||||
this.program = f.code;
|
||||
this.function_id = f.function_id;
|
||||
this.variables = [];
|
||||
for (var i = 0; i < f.num_vars; i++)
|
||||
this.variables.push(0);
|
||||
@@ -69,6 +69,8 @@ var ProgramState = function(parsed_file, callback_dict) {
|
||||
}
|
||||
}
|
||||
|
||||
this.breakpoints = [];
|
||||
|
||||
// Memory is just a big array of bytes, right?
|
||||
// "Allocation" is appending onto this array
|
||||
// A pointer to memory is an index into this array.
|
||||
@@ -341,7 +343,7 @@ ProgramState.prototype.step = function() {
|
||||
}
|
||||
log("Calling native function with index " + index + " with arguments " +
|
||||
arg_array);
|
||||
this.push(native_function(arg_array));
|
||||
this.push(native_function(arg_array, this));
|
||||
break;
|
||||
|
||||
// Memory allocation operations:
|
||||
@@ -470,8 +472,11 @@ ProgramState.prototype.step = function() {
|
||||
}
|
||||
}
|
||||
|
||||
// Takes in a parsed .bc0 file and runs it
|
||||
function execute(file, callbacks, v) {
|
||||
ProgramState.prototype.set_breakpoint = function(function_index, opcode_index) {
|
||||
this.breakpoints.push([function_index, opcode_index]);
|
||||
}
|
||||
|
||||
function initialize_vm(file, callbacks, v) {
|
||||
verbose = typeof v !== 'undefined' ? v : true;
|
||||
log("Initializing with file " + file);
|
||||
|
||||
@@ -481,25 +486,50 @@ function execute(file, callbacks, v) {
|
||||
|
||||
log("Beginning execution");
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function run_vm(vm) {
|
||||
while (true) {
|
||||
var val = state.step();
|
||||
if (val !== undefined) return val;
|
||||
for (breakpoint in vm.breakpoints) {
|
||||
if (vm.frame.function_id == breakpoint[0] &&
|
||||
vm.frame.pc == breakpoint[1]) {
|
||||
console.log("Breakpoint reached!");
|
||||
return vm;
|
||||
}
|
||||
}
|
||||
|
||||
var val = vm.step();
|
||||
if (val !== undefined) return vm;
|
||||
|
||||
if (verbose) {
|
||||
console.log("Machine state:");
|
||||
console.log("Machine vm:");
|
||||
console.log(" Current Stack Frame:");
|
||||
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(" Heap: " + state.heap);
|
||||
console.log(" Stack: " + vm.frame.stack);
|
||||
console.log(" PC: " + vm.frame.pc);
|
||||
console.log(" Vars: " + vm.frame.variables);
|
||||
// console.log(" Code: " + vm.frame.program);
|
||||
console.log(" Heap: " + vm.heap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (at_breakpoint) {
|
||||
// save state (maybe in a global in this file?)
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
// Takes in a parsed .bc0 file and runs it
|
||||
function execute(file, callbacks, v) {
|
||||
var state = initialize_vm(file, callbacks, v);
|
||||
return run_vm(state);
|
||||
}
|
||||
|
||||
function push(v) {
|
||||
console.log("Pretend I pushed " + v);
|
||||
}
|
||||
|
||||
|
||||
exports.execute = execute;
|
||||
exports.initialize_vm = initialize_vm;
|
||||
exports.run_vm = run_vm;
|
||||
exports.push = push;
|
||||
|
||||
@@ -2,38 +2,68 @@ parser = require("./bytecode-parser");
|
||||
c0vm = require("./c0vm.js");
|
||||
c0ffi = require("./c0ffi.js");
|
||||
|
||||
// console.log("Reading in sample bytecode file:");
|
||||
// console.log(parser.getBytes("../test/test.bc0"));
|
||||
// console.log("That was the sample bytecode file" +
|
||||
// " -- it probably took up your whole terminal screen.");
|
||||
// var file = parser.parse("../test/test.bc0");
|
||||
// console.log(file);
|
||||
// console.log(file.function_pool[0].code);
|
||||
|
||||
// UI interaction functions
|
||||
|
||||
function print(arg) {
|
||||
$("#output").append(arg);
|
||||
$("#output").val($("#output").val() + arg);
|
||||
}
|
||||
|
||||
callbacks = {};
|
||||
callbacks[c0ffi.NATIVE_PRINT] = function(args) {
|
||||
print(args[0]);
|
||||
print("<br />");
|
||||
return 0;
|
||||
}
|
||||
callbacks = c0ffi.default_callbacks;
|
||||
|
||||
callbacks[c0ffi.NATIVE_PRINTINT] = function(args) {
|
||||
print(args[0]);
|
||||
print("<br />");
|
||||
return 0;
|
||||
}
|
||||
// conio
|
||||
callbacks[c0ffi.NATIVE_PRINT] = function(args) {
|
||||
print(args[0]);
|
||||
return 0;
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTLN] = function(args) {
|
||||
print(args[0]);
|
||||
print("\n");
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTBOOL] = function(args) {
|
||||
if (args[0])
|
||||
print("false");
|
||||
else
|
||||
print("true");
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTCHAR] = function(args) {
|
||||
print(String.fromCharCode(args[0]));
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_READLINE] = function(args) {
|
||||
return prompt("","");
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTINT] = function(args) {
|
||||
print(args[0]);
|
||||
}
|
||||
|
||||
console.log(callbacks);
|
||||
console.log(callbacks);
|
||||
|
||||
$("#run").click(function() {
|
||||
var input = $("#bytecode").html().replace(/(\r\n|\n|\r)/gm,"");
|
||||
var file = parser.parse($("#bytecode").text());
|
||||
print("<br />");
|
||||
print(c0vm.execute(file, callbacks));
|
||||
var input = $("#bytecode").val().replace(/(\r\n|\n|\r)/gm,"");
|
||||
|
||||
$("#output").val("");
|
||||
|
||||
var file = parser.parse($("#bytecode").val());
|
||||
state = c0vm.execute(file, callbacks, true);
|
||||
state = c0vm.initialize_vm(file, callbacks, true);
|
||||
});
|
||||
|
||||
$("#break").click(function() {
|
||||
var input = $("#breakpoints").val().replace(/(\r\n|\n|\r)/gm,"");
|
||||
var temp = input.split(",");
|
||||
for (a in temp) {
|
||||
temp2 = temp[a].split(" ");
|
||||
state.set_breakpoint(parseInt(temp2[0], 10), parseInt(temp2[1], 10));
|
||||
}
|
||||
|
||||
$("#output").val("");
|
||||
$("#breakpoints").val("");
|
||||
$("#internals").val("");
|
||||
});
|
||||
|
||||
$("#continue").click(function () {
|
||||
c0vm.run_vm(state);
|
||||
});
|
||||
|
||||
$("#step").click(function () {
|
||||
state.step();
|
||||
});
|
||||
|
||||
244
public/vm/vm.js
244
public/vm/vm.js
@@ -131,6 +131,7 @@ var Bc0File = function (filename) {
|
||||
this.function_pool = [];
|
||||
for (var i = 0; i < this.function_count; i++) {
|
||||
this.function_pool.push(new FunctionInfo(stream));
|
||||
this.function_pool[i].function_id = i;
|
||||
}
|
||||
|
||||
this.native_count = stream.get_u2();
|
||||
@@ -239,34 +240,90 @@ exports.NATIVE_FILE_READLINE = 68
|
||||
exports.NATIVE_IMAGE_CLONE = 69
|
||||
exports.NATIVE_IMAGE_CREATE = 70
|
||||
exports.NATIVE_IMAGE_DATA = 71
|
||||
exports.NATIVE_IMAGE_DESTROY = 72
|
||||
exports.NATIVE_IMAGE_HEIGHT = 73
|
||||
exports.NATIVE_IMAGE_LOAD = 74
|
||||
exports.NATIVE_IMAGE_SAVE = 75
|
||||
exports.NATIVE_IMAGE_SUBIMAGE = 76
|
||||
exports.NATIVE_IMAGE_WIDTH = 77
|
||||
exports.NATIVE_IMAGE_HEIGHT = 72
|
||||
exports.NATIVE_IMAGE_LOAD = 73
|
||||
exports.NATIVE_IMAGE_SAVE = 74
|
||||
exports.NATIVE_IMAGE_SUBIMAGE = 75
|
||||
exports.NATIVE_IMAGE_WIDTH = 76
|
||||
|
||||
/* parse */
|
||||
exports.NATIVE_PARSE_BOOL = 78
|
||||
exports.NATIVE_PARSE_INT = 79
|
||||
exports.NATIVE_INT_TOKENS = 77
|
||||
exports.NATIVE_NUM_TOKENS = 78
|
||||
exports.NATIVE_PARSE_BOOL = 79
|
||||
exports.NATIVE_PARSE_INT = 80
|
||||
exports.NATIVE_PARSE_INTS = 81
|
||||
exports.NATIVE_PARSE_TOKENS = 82
|
||||
|
||||
/* string */
|
||||
exports.NATIVE_CHAR_CHR = 80
|
||||
exports.NATIVE_CHAR_ORD = 81
|
||||
exports.NATIVE_STRING_CHARAT = 82
|
||||
exports.NATIVE_STRING_COMPARE = 83
|
||||
exports.NATIVE_STRING_EQUAL = 84
|
||||
exports.NATIVE_STRING_FROM_CHARARRAY = 85
|
||||
exports.NATIVE_STRING_FROMBOOL = 86
|
||||
exports.NATIVE_STRING_FROMCHAR = 87
|
||||
exports.NATIVE_STRING_FROMINT = 88
|
||||
exports.NATIVE_STRING_JOIN = 89
|
||||
exports.NATIVE_STRING_LENGTH = 90
|
||||
exports.NATIVE_STRING_SUB = 91
|
||||
exports.NATIVE_STRING_TERMINATED = 92
|
||||
exports.NATIVE_STRING_TO_CHARARRAY = 93
|
||||
exports.NATIVE_STRING_TOLOWER = 94
|
||||
exports.NATIVE_CHAR_CHR = 83
|
||||
exports.NATIVE_CHAR_ORD = 84
|
||||
exports.NATIVE_STRING_CHARAT = 85
|
||||
exports.NATIVE_STRING_COMPARE = 86
|
||||
exports.NATIVE_STRING_EQUAL = 87
|
||||
exports.NATIVE_STRING_FROM_CHARARRAY = 88
|
||||
exports.NATIVE_STRING_FROMBOOL = 89
|
||||
exports.NATIVE_STRING_FROMCHAR = 90
|
||||
exports.NATIVE_STRING_FROMINT = 91
|
||||
exports.NATIVE_STRING_JOIN = 92
|
||||
exports.NATIVE_STRING_LENGTH = 93
|
||||
exports.NATIVE_STRING_SUB = 94
|
||||
exports.NATIVE_STRING_TERMINATED = 95
|
||||
exports.NATIVE_STRING_TO_CHARARRAY = 96
|
||||
exports.NATIVE_STRING_TOLOWER = 97
|
||||
|
||||
callbacks = {};
|
||||
callbacks[exports.NATIVE_STRING_LENGTH] =
|
||||
function(args) {
|
||||
return args[0].length;
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_STRING_TO_CHARARRAY] =
|
||||
function(args, vm) {
|
||||
var address = vm.heap.length;
|
||||
vm.heap.push(args[0].length+1);
|
||||
vm.heap.push(1);
|
||||
for (var i = 0; i < args[0].length; i++) {
|
||||
vm.heap.push(args[0][i]);
|
||||
}
|
||||
vm.heap.push(0);
|
||||
return address;
|
||||
};
|
||||
|
||||
|
||||
callbacks[exports.NATIVE_STRING_FROM_CHARARRAY] =
|
||||
function(args, vm) {
|
||||
var i = args[0] + 2;
|
||||
var result = "";
|
||||
while (vm.heap[i] !== 0) {
|
||||
result += vm.heap[i];
|
||||
i++;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_CHAR_CHR] =
|
||||
function(args) {
|
||||
return String.fromCharCode(args[0]);
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_CHAR_ORD] =
|
||||
function(args) {
|
||||
if (typeof args[0] == "string")
|
||||
return args[0].charCodeAt(0);
|
||||
return args[0];
|
||||
};
|
||||
|
||||
callbacks[exports.NATIVE_STRING_COMPARE] = function(args) {
|
||||
if (args[0] < args[1]) return -1;
|
||||
if (args[0] > args[1]) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
callbacks[exports.NATIVE_STRING_EQUAL] = function(args) {
|
||||
return args[0] === args[1];
|
||||
}
|
||||
|
||||
exports.default_callbacks = callbacks;
|
||||
|
||||
},{}],4:[function(require,module,exports){
|
||||
op = require("./opcodes");
|
||||
@@ -274,9 +331,8 @@ op = require("./opcodes");
|
||||
var INT_MIN = 0x80000000;
|
||||
var INT_MAX = 0x7FFFFFFF;
|
||||
|
||||
var verbose = false;
|
||||
function log(message) {
|
||||
if (verbose) console.log(message);
|
||||
if (verbose) $("#internals").val($("#internals").val() + "\n" + message);
|
||||
}
|
||||
|
||||
function c0_assertion_failure(val) {
|
||||
@@ -299,7 +355,6 @@ function i32_to_array(i32) {
|
||||
((i32 >> 8) & 0xFF),
|
||||
((i32 >> 16) & 0xFF),
|
||||
((i32 >> 24) & 0xFF)];
|
||||
|
||||
}
|
||||
|
||||
function array_to_i32(array) {
|
||||
@@ -314,6 +369,7 @@ var StackFrame = function(file, f) {
|
||||
this.stack = [];
|
||||
this.pc = 0;
|
||||
this.program = f.code;
|
||||
this.function_id = f.function_id;
|
||||
this.variables = [];
|
||||
for (var i = 0; i < f.num_vars; i++)
|
||||
this.variables.push(0);
|
||||
@@ -341,6 +397,8 @@ var ProgramState = function(parsed_file, callback_dict) {
|
||||
}
|
||||
}
|
||||
|
||||
this.breakpoints = [];
|
||||
|
||||
// Memory is just a big array of bytes, right?
|
||||
// "Allocation" is appending onto this array
|
||||
// A pointer to memory is an index into this array.
|
||||
@@ -613,7 +671,7 @@ ProgramState.prototype.step = function() {
|
||||
}
|
||||
log("Calling native function with index " + index + " with arguments " +
|
||||
arg_array);
|
||||
this.push(native_function(arg_array));
|
||||
this.push(native_function(arg_array, this));
|
||||
break;
|
||||
|
||||
// Memory allocation operations:
|
||||
@@ -742,8 +800,11 @@ ProgramState.prototype.step = function() {
|
||||
}
|
||||
}
|
||||
|
||||
// Takes in a parsed .bc0 file and runs it
|
||||
function execute(file, callbacks, v) {
|
||||
ProgramState.prototype.set_breakpoint = function(function_index, opcode_index) {
|
||||
this.breakpoints.push([function_index, opcode_index]);
|
||||
}
|
||||
|
||||
function initialize_vm(file, callbacks, v) {
|
||||
verbose = typeof v !== 'undefined' ? v : true;
|
||||
log("Initializing with file " + file);
|
||||
|
||||
@@ -753,68 +814,123 @@ function execute(file, callbacks, v) {
|
||||
|
||||
log("Beginning execution");
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
function run_vm(vm) {
|
||||
while (true) {
|
||||
var val = state.step();
|
||||
if (val !== undefined) return val;
|
||||
for (breakpoint in vm.breakpoints) {
|
||||
if (vm.frame.function_id == breakpoint[0] &&
|
||||
vm.frame.pc == breakpoint[1]) {
|
||||
console.log("Breakpoint reached!");
|
||||
return vm;
|
||||
}
|
||||
}
|
||||
|
||||
var val = vm.step();
|
||||
if (val !== undefined) return vm;
|
||||
|
||||
if (verbose) {
|
||||
console.log("Machine state:");
|
||||
console.log("Machine vm:");
|
||||
console.log(" Current Stack Frame:");
|
||||
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(" Heap: " + state.heap);
|
||||
console.log(" Stack: " + vm.frame.stack);
|
||||
console.log(" PC: " + vm.frame.pc);
|
||||
console.log(" Vars: " + vm.frame.variables);
|
||||
// console.log(" Code: " + vm.frame.program);
|
||||
console.log(" Heap: " + vm.heap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (at_breakpoint) {
|
||||
// save state (maybe in a global in this file?)
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
// Takes in a parsed .bc0 file and runs it
|
||||
function execute(file, callbacks, v) {
|
||||
var state = initialize_vm(file, callbacks, v);
|
||||
return run_vm(state);
|
||||
}
|
||||
|
||||
function push(v) {
|
||||
console.log("Pretend I pushed " + v);
|
||||
}
|
||||
|
||||
|
||||
exports.execute = execute;
|
||||
exports.initialize_vm = initialize_vm;
|
||||
exports.run_vm = run_vm;
|
||||
exports.push = push;
|
||||
|
||||
},{"./opcodes":6}],5:[function(require,module,exports){
|
||||
parser = require("./bytecode-parser");
|
||||
c0vm = require("./c0vm.js");
|
||||
c0ffi = require("./c0ffi.js");
|
||||
|
||||
// console.log("Reading in sample bytecode file:");
|
||||
// console.log(parser.getBytes("../test/test.bc0"));
|
||||
// console.log("That was the sample bytecode file" +
|
||||
// " -- it probably took up your whole terminal screen.");
|
||||
// var file = parser.parse("../test/test.bc0");
|
||||
// console.log(file);
|
||||
// console.log(file.function_pool[0].code);
|
||||
|
||||
// UI interaction functions
|
||||
|
||||
function print(arg) {
|
||||
$("#output").append(arg);
|
||||
$("#output").val($("#output").val() + arg);
|
||||
}
|
||||
|
||||
callbacks = {};
|
||||
callbacks[c0ffi.NATIVE_PRINT] = function(args) {
|
||||
print(args[0]);
|
||||
print("<br />");
|
||||
return 0;
|
||||
}
|
||||
callbacks = c0ffi.default_callbacks;
|
||||
|
||||
callbacks[c0ffi.NATIVE_PRINTINT] = function(args) {
|
||||
print(args[0]);
|
||||
print("<br />");
|
||||
return 0;
|
||||
}
|
||||
// conio
|
||||
callbacks[c0ffi.NATIVE_PRINT] = function(args) {
|
||||
print(args[0]);
|
||||
return 0;
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTLN] = function(args) {
|
||||
print(args[0]);
|
||||
print("\n");
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTBOOL] = function(args) {
|
||||
if (args[0])
|
||||
print("false");
|
||||
else
|
||||
print("true");
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTCHAR] = function(args) {
|
||||
print(String.fromCharCode(args[0]));
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_READLINE] = function(args) {
|
||||
return prompt("","");
|
||||
}
|
||||
callbacks[c0ffi.NATIVE_PRINTINT] = function(args) {
|
||||
print(args[0]);
|
||||
}
|
||||
|
||||
console.log(callbacks);
|
||||
console.log(callbacks);
|
||||
|
||||
$("#run").click(function() {
|
||||
var input = $("#bytecode").html().replace(/(\r\n|\n|\r)/gm,"");
|
||||
var file = parser.parse($("#bytecode").text());
|
||||
print("<br />");
|
||||
print(c0vm.execute(file, callbacks));
|
||||
var input = $("#bytecode").val().replace(/(\r\n|\n|\r)/gm,"");
|
||||
|
||||
$("#output").val("");
|
||||
|
||||
var file = parser.parse($("#bytecode").val());
|
||||
state = c0vm.execute(file, callbacks, true);
|
||||
state = c0vm.initialize_vm(file, callbacks, true);
|
||||
});
|
||||
|
||||
$("#break").click(function() {
|
||||
var input = $("#breakpoints").val().replace(/(\r\n|\n|\r)/gm,"");
|
||||
var temp = input.split(",");
|
||||
for (a in temp) {
|
||||
temp2 = temp[a].split(" ");
|
||||
state.set_breakpoint(parseInt(temp2[0], 10), parseInt(temp2[1], 10));
|
||||
}
|
||||
|
||||
$("#output").val("");
|
||||
$("#breakpoints").val("");
|
||||
$("#internals").val("");
|
||||
});
|
||||
|
||||
$("#continue").click(function () {
|
||||
c0vm.run_vm(state);
|
||||
});
|
||||
|
||||
$("#step").click(function () {
|
||||
state.step();
|
||||
});
|
||||
|
||||
},{"./bytecode-parser":2,"./c0ffi.js":3,"./c0vm.js":4}],6:[function(require,module,exports){
|
||||
@@ -926,4 +1042,4 @@ exports.lookup_table = {
|
||||
|
||||
},{}],7:[function(require,module,exports){
|
||||
|
||||
},{}]},{},[4,2,1,6,5]);
|
||||
},{}]},{},[4,2,1,6,3,5]);
|
||||
|
||||
110
src/c0ffi.js
110
src/c0ffi.js
@@ -1,110 +0,0 @@
|
||||
exports.NATIVE_FADD = 0
|
||||
exports.NATIVE_FDIV = 1
|
||||
exports.NATIVE_FLESS = 2
|
||||
exports.NATIVE_FMUL = 3
|
||||
exports.NATIVE_FSUB = 4
|
||||
exports.NATIVE_FTOI = 5
|
||||
exports.NATIVE_ITOF = 6
|
||||
exports.NATIVE_PRINT_FPT = 7
|
||||
exports.NATIVE_PRINT_HEX = 8
|
||||
exports.NATIVE_PRINT_INT = 9
|
||||
|
||||
/* args */
|
||||
exports.NATIVE_ARGS_FLAG = 10
|
||||
exports.NATIVE_ARGS_INT = 11
|
||||
exports.NATIVE_ARGS_PARSE = 12
|
||||
exports.NATIVE_ARGS_STRING = 13
|
||||
|
||||
/* conio */
|
||||
exports.NATIVE_EOF = 14
|
||||
exports.NATIVE_FLUSH = 15
|
||||
exports.NATIVE_PRINT = 16
|
||||
exports.NATIVE_PRINTBOOL = 17
|
||||
exports.NATIVE_PRINTCHAR = 18
|
||||
exports.NATIVE_PRINTINT = 19
|
||||
exports.NATIVE_PRINTLN = 20
|
||||
exports.NATIVE_READLINE = 21
|
||||
|
||||
/* curses */
|
||||
exports.NATIVE_C_ADDCH = 22
|
||||
exports.NATIVE_C_CBREAK = 23
|
||||
exports.NATIVE_C_CURS_SET = 24
|
||||
exports.NATIVE_C_DELCH = 25
|
||||
exports.NATIVE_C_ENDWIN = 26
|
||||
exports.NATIVE_C_ERASE = 27
|
||||
exports.NATIVE_C_GETCH = 28
|
||||
exports.NATIVE_C_INITSCR = 29
|
||||
exports.NATIVE_C_KEYPAD = 30
|
||||
exports.NATIVE_C_MOVE = 31
|
||||
exports.NATIVE_C_NOECHO = 32
|
||||
exports.NATIVE_C_REFRESH = 33
|
||||
exports.NATIVE_C_SUBWIN = 34
|
||||
exports.NATIVE_C_WADDCH = 35
|
||||
exports.NATIVE_C_WADDSTR = 36
|
||||
exports.NATIVE_C_WCLEAR = 37
|
||||
exports.NATIVE_C_WERASE = 38
|
||||
exports.NATIVE_C_WMOVE = 39
|
||||
exports.NATIVE_C_WREFRESH = 40
|
||||
exports.NATIVE_C_WSTANDEND = 41
|
||||
exports.NATIVE_C_WSTANDOUT = 42
|
||||
exports.NATIVE_CC_GETBEGX = 43
|
||||
exports.NATIVE_CC_GETBEGY = 44
|
||||
exports.NATIVE_CC_GETMAXX = 45
|
||||
exports.NATIVE_CC_GETMAXY = 46
|
||||
exports.NATIVE_CC_GETX = 47
|
||||
exports.NATIVE_CC_GETY = 48
|
||||
exports.NATIVE_CC_HIGHLIGHT = 49
|
||||
exports.NATIVE_CC_KEY_IS_BACKSPACE = 50
|
||||
exports.NATIVE_CC_KEY_IS_DOWN = 51
|
||||
exports.NATIVE_CC_KEY_IS_ENTER = 52
|
||||
exports.NATIVE_CC_KEY_IS_LEFT = 53
|
||||
exports.NATIVE_CC_KEY_IS_RIGHT = 54
|
||||
exports.NATIVE_CC_KEY_IS_UP = 55
|
||||
exports.NATIVE_CC_WBOLDOFF = 56
|
||||
exports.NATIVE_CC_WBOLDON = 57
|
||||
exports.NATIVE_CC_WDIMOFF = 58
|
||||
exports.NATIVE_CC_WDIMON = 59
|
||||
exports.NATIVE_CC_WREVERSEOFF = 60
|
||||
exports.NATIVE_CC_WREVERSEON = 61
|
||||
exports.NATIVE_CC_WUNDEROFF = 62
|
||||
exports.NATIVE_CC_WUNDERON = 63
|
||||
|
||||
/* file */
|
||||
exports.NATIVE_FILE_CLOSE = 64
|
||||
exports.NATIVE_FILE_CLOSED = 65
|
||||
exports.NATIVE_FILE_EOF = 66
|
||||
exports.NATIVE_FILE_READ = 67
|
||||
exports.NATIVE_FILE_READLINE = 68
|
||||
|
||||
/* img */
|
||||
exports.NATIVE_IMAGE_CLONE = 69
|
||||
exports.NATIVE_IMAGE_CREATE = 70
|
||||
exports.NATIVE_IMAGE_DATA = 71
|
||||
exports.NATIVE_IMAGE_DESTROY = 72
|
||||
exports.NATIVE_IMAGE_HEIGHT = 73
|
||||
exports.NATIVE_IMAGE_LOAD = 74
|
||||
exports.NATIVE_IMAGE_SAVE = 75
|
||||
exports.NATIVE_IMAGE_SUBIMAGE = 76
|
||||
exports.NATIVE_IMAGE_WIDTH = 77
|
||||
|
||||
/* parse */
|
||||
exports.NATIVE_PARSE_BOOL = 78
|
||||
exports.NATIVE_PARSE_INT = 79
|
||||
|
||||
/* string */
|
||||
exports.NATIVE_CHAR_CHR = 80
|
||||
exports.NATIVE_CHAR_ORD = 81
|
||||
exports.NATIVE_STRING_CHARAT = 82
|
||||
exports.NATIVE_STRING_COMPARE = 83
|
||||
exports.NATIVE_STRING_EQUAL = 84
|
||||
exports.NATIVE_STRING_FROM_CHARARRAY = 85
|
||||
exports.NATIVE_STRING_FROMBOOL = 86
|
||||
exports.NATIVE_STRING_FROMCHAR = 87
|
||||
exports.NATIVE_STRING_FROMINT = 88
|
||||
exports.NATIVE_STRING_JOIN = 89
|
||||
exports.NATIVE_STRING_LENGTH = 90
|
||||
exports.NATIVE_STRING_SUB = 91
|
||||
exports.NATIVE_STRING_TERMINATED = 92
|
||||
exports.NATIVE_STRING_TO_CHARARRAY = 93
|
||||
exports.NATIVE_STRING_TOLOWER = 94
|
||||
|
||||
@@ -2,7 +2,8 @@ parser = require("../src/bytecode-parser.js");
|
||||
c0vm = require("../src/c0vm.js");
|
||||
c0ffi = require("../src/c0ffi.js");
|
||||
|
||||
var callbacks = {}
|
||||
var callbacks = c0ffi.default_callbacks;
|
||||
console.log("Initial callbacks: " + callbacks[c0ffi.NATIVE_STRING_LENGTH](["hi"]));
|
||||
var printout = "";
|
||||
|
||||
callbacks[c0ffi.NATIVE_PRINT] = function(args) {
|
||||
@@ -20,30 +21,6 @@ callbacks[c0ffi.NATIVE_PRINTLN] = function(args) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
callbacks[c0ffi.NATIVE_STRING_LENGTH] = function(args) {
|
||||
return args[0].length;
|
||||
}
|
||||
|
||||
callbacks[c0ffi.NATIVE_STRING_TO_CHARARRAY] = function(args) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
callbacks[c0ffi.NATIVE_STRING_FROM_CHARARRAY] = function(args) {
|
||||
console.log("string_from_chararray: " + args);
|
||||
return args[0];
|
||||
}
|
||||
|
||||
callbacks[c0ffi.NATIVE_CHAR_CHR] = function(args) {
|
||||
return String.fromCharCode(args[0]);
|
||||
}
|
||||
|
||||
callbacks[c0ffi.NATIVE_CHAR_ORD] = function(args) {
|
||||
console.log("native_car_ord: " + args);
|
||||
if (typeof args[0] == "string")
|
||||
return args[0].charCodeAt(0);
|
||||
return args[0];
|
||||
}
|
||||
|
||||
function doTest(filename, expected_result) {
|
||||
return function(test) {
|
||||
var result = c0vm.execute(parser.parse(filename), callbacks, false);
|
||||
|
||||
@@ -5,9 +5,7 @@ html
|
||||
|
||||
link(rel="stylesheet"
|
||||
href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css")
|
||||
link(rel="stylesheet" href="/site.css")
|
||||
|
||||
link(rel="stylesheet" href="sh_emacs.min.css")
|
||||
link(rel="stylesheet" href="/css/site.css")
|
||||
|
||||
block head
|
||||
|
||||
|
||||
@@ -3,9 +3,6 @@ extends base
|
||||
block head
|
||||
title c0db
|
||||
|
||||
link(rel="stylesheet" href="/codemirror.css")
|
||||
|
||||
|
||||
block nav
|
||||
+navbar("home")
|
||||
|
||||
@@ -19,23 +16,35 @@ block body
|
||||
button(onclick="compile()" type="button").btn.btn-default.btm-btn.pull-right Compile
|
||||
#codearea
|
||||
textarea.code.formControl.sh_c(rows="12" id="inputCode")
|
||||
|
||||
.col-md-6
|
||||
p.lbl.
|
||||
Bytecode
|
||||
pre#bytecode.panel.panel-default.code.sh_c.
|
||||
|
||||
form
|
||||
.form-group
|
||||
label(for="bytecode") Bytecode
|
||||
button(type="button")#run.btn.btn-default.btm-btn.pull-right Run
|
||||
textarea.code.formControl.sh_c(rows="12" id="bytecode")
|
||||
.row
|
||||
.col-md-12
|
||||
p.lbl.
|
||||
Output
|
||||
button(type="button")#run.btn.btn-default.btm-btn.pull-right Run
|
||||
pre#output.panel.panel-default.code
|
||||
|
||||
|
||||
.col-md-3
|
||||
form
|
||||
.form-group
|
||||
label(for="output") Output
|
||||
button(type="button")#continue.no_disp.btn.btn-default.btm-btn.pull-right Continue
|
||||
button(type="button")#step.no_disp.btn.btn-default.btm-btn.pull-right Step
|
||||
textarea.code.sh_c(id="output")
|
||||
.col-md-6
|
||||
form
|
||||
.form-group
|
||||
label(for="internals") Stack Output
|
||||
button(type="button")#download.btn.btn-default.btm-btn.pull-right Download
|
||||
textarea.code.sh_c(rows="12" id="internals")
|
||||
.col-md-3
|
||||
form
|
||||
.form-group
|
||||
label(for="breakpoints") Breakpoints
|
||||
button(type="button")#break.btn.btn-default.btm-btn.pull-right Save
|
||||
textarea.code.sh_c(id="breakpoints")
|
||||
|
||||
block script
|
||||
script(type="text/javascript" src="codemirror-compressed.js")
|
||||
script(type="text/javascript" src="js/codemirror-compressed.js")
|
||||
script(type="text/javascript" src="vm/vm.js")
|
||||
|
||||
script(type='text/javascript').
|
||||
@@ -47,15 +56,14 @@ block script
|
||||
|
||||
function compile() {
|
||||
var code = encodeURIComponent($("#inputCode").val());
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
async: true,
|
||||
url: "http://www.contrib.andrew.cmu.edu/~amgutier/cc0.cgi",
|
||||
dataType: "jsonp",
|
||||
dataType: "json",
|
||||
data: {
|
||||
data: code
|
||||
},
|
||||
jsonpCallback: "callback"
|
||||
success: callback
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user