Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECE - Evaluate Subtyping #22

Merged
merged 32 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
92997c2
Add location to nodeCreator
xyliew25 Mar 15, 2024
4eec0ca
Push target for RES_OVERLOAD regardless of instance/static
xyliew25 Mar 15, 2024
b8d0855
Resolve method overloading with subtyping
xyliew25 Mar 15, 2024
b6933df
Initial attempt for doc
xyliew25 Mar 16, 2024
c8eb9a0
Return context even evaluation failed
xyliew25 Mar 18, 2024
ad12ad8
Handle interpreting language error
xyliew25 Mar 18, 2024
f865382
Declare implicit Object class
xyliew25 Mar 22, 2024
73be850
Extract NullLiteral
xyliew25 Mar 22, 2024
d55d040
Create diff frames for new obj and set alias to static fields
xyliew25 Mar 22, 2024
1084948
Support name resolution for subtyping
xyliew25 Mar 22, 2024
01cd6a7
Push target on stash regardless instance/static mtd for res_override use
xyliew25 Mar 22, 2024
c7f6cf8
Throw ambiguous method overloading resolution error
xyliew25 Mar 22, 2024
42cd2ff
Make non local var simple name qualified
xyliew25 Mar 22, 2024
be97f81
Add test for more complex qualified name resolution
xyliew25 Mar 22, 2024
44e7760
Evaluate more complex qualified method invocation
xyliew25 Mar 22, 2024
e081dff
Evaluate more complex qualified method invocation with instance field
xyliew25 Mar 23, 2024
349a92b
Fix tests on explicit constructor invocation to Object()
xyliew25 Mar 23, 2024
a074775
Extend mtd frame from global env
xyliew25 Mar 24, 2024
620874a
Prepend instance field init only if alternate constructor invocation …
xyliew25 Mar 25, 2024
bbbe0a1
Add test for superclass constructor invocation
xyliew25 Mar 25, 2024
90e272a
Break obj extension from class
xyliew25 Mar 25, 2024
2e7d327
Restructure test files
xyliew25 Mar 30, 2024
4141ff9
Remove debugging logs
xyliew25 Mar 30, 2024
def8a4f
Extract constants
xyliew25 Mar 30, 2024
165c394
Add classDecl ref to Class
xyliew25 Mar 30, 2024
081b753
Add objects getter
xyliew25 Mar 30, 2024
155c3ac
Extract structs
xyliew25 Mar 30, 2024
5700b2d
Remove done TODO
xyliew25 Mar 30, 2024
e158d9f
Implement astToString()
xyliew25 Mar 30, 2024
4e0564a
Refactor: Pass Environment instead of Context
xyliew25 Mar 31, 2024
e5545ad
Refactor code
xyliew25 Apr 1, 2024
c2b188d
Update scope doc
xyliew25 Apr 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Initial attempt for doc
  • Loading branch information
xyliew25 committed Mar 16, 2024
commit b6933dfc85e66bcd7089b42be67837458021bb82
17 changes: 17 additions & 0 deletions src/ec-evaluator/docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PDFLATEX = latexmk -pdf

SPECSNUMS = 1

SPECS = $(SPECSNUMS:%=java_%)

PDFSPECS = $(SPECS:%=%.pdf)

HELPERSTEX = $(HELPERS:%=java_%.tex)

all: $(PDFSPECS)

%.pdf: %.tex
$(PDFLATEX) $*

clean:
rm -f *~ *.dvi *.aux *.log *.ps *.out *.pdf *.fls *.fdb_latexmk
15 changes: 15 additions & 0 deletions src/ec-evaluator/docs/java_1.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\input java_header.tex

\begin{document}

\docheader{2024}{Java}{\S 1}{Martin Henz, Liew Xin Yi}

\input java_intro.tex

\input java_bnf.tex

\input java_1_bnf.tex

\input java_1_bnf_cont.tex

\end{document}
43 changes: 43 additions & 0 deletions src/ec-evaluator/docs/java_1_bnf.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
\begin{alignat*}{9}
&& \textit{compilation-unit} && \quad ::= & \quad && \textit{class-declaration} ... && \\[2mm]
&& \textit{class-declaration} && \quad ::= & \quad && \textbf{\texttt{class}} \ \textit{identifier} \ [ \ \textbf{\texttt{extends}} \ \textit{identifier} \ ] \ \textit{class-body} && \\[1mm]
&& \textit{class-body} && \quad ::= & \quad && \textbf{\texttt{\{}} \textit{class-body-declaration} ... \textbf{\texttt{\}}} && \\[1mm]
&& \textit{class-body-declaration} && \quad ::= & \quad && \textit{field-declaration} && \\
&& && | & \quad && \textit{constructor-declaration} && \\
&& && | & \quad && \textit{method-declaration} && \\[2mm]
&& \textit{field-declaration} && \quad ::= & \quad && \textit{field-modifier} ... \ \textit{type} \ \textit{identifier} \ [ \ \textbf{\texttt{=}} \ \textit{expression} \ ] \ \textbf{\texttt{;}} && \\[1mm]
&& \textit{field-modifier} && \quad ::= & \quad && \textbf{\texttt{static}} && \\[1mm]
&& \textit{method-declaration} && \quad ::= & \quad && \textit{method-modifier} ... \ \textit{method-header} \ \textit{block} && \\[1mm]
&& \textit{method-modifier} && \quad ::= & \quad && \textbf{\texttt{static}} && \\[1mm]
&& \textit{method-header} && \quad ::= & \quad && \textit{result-type} \ \textit{method-declarator} && \\[1mm]
&& \textit{result-type} && \quad ::= & \quad && \textit{type} \ | \ \textbf{\texttt{void}} && \\[1mm]
&& \textit{method-declarator} && \quad ::= & \quad && \textit{identifier} \ \textbf{\texttt{(}} \textit{formal-parameter} ... \textbf{\texttt{)}} && \\[1mm]
&& \textit{formal-parameter} && \quad ::= & \quad && \textit{type} \ \textit{identifer} && \\[2mm]
&& \textit{constructor-declaration} && \quad ::= & \quad && \textit{identifier} \ \textbf{\texttt{(}} \textit{formal-parameter} ... \textbf{\texttt{)}} \ \textit{block} && \\[2mm]
&& \textit{type} && \quad ::= & \quad && \textit{primitive-type} \ | \ \textit{reference-type} && \\[1mm]
&& \textit{primitive-type} && \quad ::= & \quad && \textbf{\texttt{int}} && \\[1mm]
&& \textit{reference-type} && \quad ::= & \quad && \textit{identifer} && \\[2mm]
&& \textit{block} && \quad ::= & \quad && \textbf{\texttt{\{}} \textit{block-statement} ... \textbf{\texttt{\}}} && \\[1mm]
&& \textit{block-statement} && \quad ::= & \quad && \textit{local-variable-declaration-statement} && \\
&& && | & \quad && \textit{expression-statement} && \\
&& && | & \quad && \textit{return-statement} && \\
&& && | & \quad && \textit{explicit-constructor-invocation} && \\[2mm]
&& \textit{local-variable-declaration-statement} && \quad ::= & \quad && \textit{type} \ \textit{identifier} \ [ \ \textbf{\texttt{=}} \ \textit{expression} \ ] \ \textbf{\texttt{;}} && \\[2mm]
&& \textit{expression-statement} && \quad ::= & \quad && \textit{statement-expression} \ \textbf{\texttt{;}} && \\[1mm]
&& \textit{statement-expression} && \quad ::= & \quad && \textit{assignment} \ | \ \textit{method-invocation} && \\[2mm]
&& \textit{return-statement} && \quad ::= & \quad && \textbf{\texttt{return}} \ [ \ \textit{expression} \ ] \ \textbf{\texttt{;}} && \\[2mm]
&& \textit{explicit-constructor-invocation} && \quad ::= & \quad && \textit{primary} \ \textbf{\texttt{(}} \textit{expression} ... \textbf{\texttt{)}} \ \textbf{\texttt{;}} && \\[2mm]
&& \textit{assignment} && \quad ::= & \quad && \textit{left-hand-side} \ \textbf{\texttt{=}} \ \textit{expression} && \\[1mm]
&& \textit{left-hand-side} && \quad ::= & \quad && \textit{expression-name} \ | \ \textit{field-access} && \\[2mm]
&& \textit{expression} && \quad ::= & \quad && \textit{binary-expression} && \\
&& && | & \quad && \textit{assignment} && \\
&& && | & \quad && \textit{expression-name} && \\
&& && | & \quad && \textit{literal} && \\
&& && | & \quad && \textit{primary} && \\
&& && | & \quad && \textit{class-instance-creation-expression} && \\
&& && | & \quad && \textit{field-access} && \\
&& && | & \quad && \textit{method-invocation} && \\[2mm]
&& \textit{binary-expression} && \quad ::= & \quad && \textit{expression} \ \textit{binary-operator} \ \textit{expression} && \\[1mm]
&& \textit{binary-operator} && \quad ::= & \quad && \textbf{\texttt{+}} \ | \ \textbf{\texttt{-}} \ | \ \textbf{\texttt{*}} \ | \ \textbf{\texttt{/}} \ | \ \textbf{\texttt{\%}} && \\[1mm]
&& \textit{primary} && \quad ::= & \quad && \textbf{\texttt{this}} \ | \ \textbf{\texttt{super}} && \\[1mm]
\end{alignat*}
10 changes: 10 additions & 0 deletions src/ec-evaluator/docs/java_1_bnf_cont.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\begin{alignat*}{9}
&& \textit{class-instance-creation-expression} && \quad ::= & \quad && \textbf{\texttt{new}} \ \textit{identifier} \ \textbf{\texttt{(}} \textit{expression} ... \textbf{\texttt{)}} && \\[2mm]
&& \textit{field-access} && \quad ::= & \quad && \textit{primary} \textbf{\texttt{.}} \textit{identifier} && \\[2mm]
&& \textit{method-invocation} && \quad ::= & \quad && \textit{expression-name} \ \textbf{\texttt{(}} \textit{expression} ... \textbf{\texttt{)}} && \\
&& && | & \quad && \textit{primary} \textbf{\texttt{.}} \textit{identifier} \ \textbf{\texttt{(}} \textit{expression} ... \textbf{\texttt{)}} && \\
&& \textit{expression-name} && \quad ::= & \quad && \textit{identifier} \ | \ \textit{expression-name} \textbf{\texttt{.}} \textit{identifier} && \\[1mm]
&& \textit{literal} && \quad ::= & \quad && number && \\
&& && | & \quad && string && \\
&& && | & \quad && \textbf{\texttt{null}} && \\[2mm]
\end{alignat*}
10 changes: 10 additions & 0 deletions src/ec-evaluator/docs/java_bnf.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
\section{Syntax}

A Java program is a \emph{program}, defined using Backus-Naur Form\footnote{
We adopt Henry Ledgard's BNF variant that he described in
\emph{A human engineered variant of BNF}, ACM SIGPLAN Notices, Volume 15 Issue 10,
October 1980, Pages 57-62. In our grammars, we use \textbf{\texttt{bold}} font for keywords,
{\it italics} for syntactic variables, $\epsilon$ for nothing,
$x\ |\ y$ for $x$ or $y$, $[\ x\ ]$ for an optional $x$,
$ x ...$ for zero or more repetitions of $x$, and $(\ x\ )$ for clarifying the structure of BNF expressions.}
as follows:
153 changes: 153 additions & 0 deletions src/ec-evaluator/docs/java_header.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
\documentclass[epic,eepic,10pt,a4paper]{article}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\usepackage{graphicx,bookman}
\usepackage{graphics}
\usepackage{CJKutf8}
\usepackage{latexsym}
\usepackage{mathtools}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}

\usepackage[T1]{fontenc}

\usepackage[paper=210mm:297mm]{typearea}

\usepackage{listings}

\lstdefinelanguage{Java}{
keywords={abstract, assert, boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, enum, extends, final, finally, float, for, goto, if, implements, import, instanceof, int, interface, long, native, new, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, throws, transient, try, void, volatile, while},
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
morestring=[b]',
morestring=[b]",
sensitive=true
}

\lstset{
language=Java,
basicstyle=\ttfamily,
showstringspaces=false,
showspaces=false,
escapechar={^}
}

\pagestyle{myheadings}

% ALIGN EVEN- AND ODD-NUMBERED PAGES.
\evensidemargin 35pt

% HORIZONTAL MARGINS
% Left margin 1 inch (0 + 1)
\setlength{\oddsidemargin}{0in}
% Text width 6.5 inch (so right margin 1 inch).
\setlength{\textwidth}{6.5in}

% ----------------
% VERTICAL MARGINS
% Top margin 0.5 inch (-0.5 + 1)
\setlength{\topmargin}{-0.5in}
% Head height 0.25 inch (where page headers go)
\setlength{\headheight}{0.25in}
% Head separation 0.25 inch (between header and top line of text)
\setlength{\headsep}{0.25in}
% Text height 8.5 inch (so bottom margin 1.5 in)
\setlength{\textheight}{10.0in}

% ----------------
% PARAGRAPH INDENTATION
\setlength{\parindent}{0in}

% SPACE BETWEEN PARAGRAPHS
%\setlength{\parskip}{\medskipamount}

% ----------------
% EVALUATION SYMBOL
\newcommand{\evalsto}{$\Longrightarrow$}

% ----------------
% STRUTS
% HORIZONTAL STRUT. One argument (width).
\newcommand{\hstrut}[1]{\hspace*{#1}}
% VERTICAL STRUT. Two arguments (offset from baseline, height).
\newcommand{\vstrut}[2]{\rule[#1]{0in}{#2}}

% ----------------
% EMPTY BOXES OF VARIOUS WIDTHS, FOR INDENTATION
\newcommand{\hm}{\hspace*{1em}}
\newcommand{\hmm}{\hspace*{2em}}
\newcommand{\hmmm}{\hspace*{3em}}
\newcommand{\hmmmm}{\hspace*{4em}}

% ----------------
% VARIOUS CONVENIENT WIDTHS RELATIVE TO THE TEXT WIDTH, FOR BOXES.
\newlength{\hlessmm}
\setlength{\hlessmm}{\textwidth}
\addtolength{\hlessmm}{-2em}

\newlength{\hlessmmmm}
\setlength{\hlessmmmm}{\textwidth}
\addtolength{\hlessmmmm}{-4em}

% ----------------
% ``TIGHTLIST'' ENVIRONMENT (no para space between items, small indent)
\newenvironment{tightlist}%
{\begin{list}{$\bullet$}{%
\setlength{\topsep}{0in}
\setlength{\partopsep}{0in}
\setlength{\itemsep}{0in}
\setlength{\parsep}{0in}
\setlength{\leftmargin}{1.5em}
\setlength{\rightmargin}{0in}
\setlength{\itemindent}{0in}
}
}%
{\end{list}
}

% ----------------
% CODE FONT (e.g. {\cf x := 0}).
\newcommand{\cf}{\footnotesize\tt}

% ----------------
% INSTRUCTION POINTER
\newcommand{\IP}{$\bullet$}
\newcommand{\goesto}{$\longrightarrow$}

% \illuswidth is used to set up boxes around illustrations.
\newlength{\illuswidth}
\setlength{\illuswidth}{\textwidth}
\addtolength{\illuswidth}{-7pt}

% PROBLEM SET HEADER -- args are semester and problem set or solution
% example: \psetheader{Spring Semester, 1989}{Problem set 1}
\newcommand{\docheader}[4]{%

\thispagestyle{empty}

\markright{#2 #3, #1}
\begin{center}
{\Large {\bf Specification of #2 #3}---#1 edition}\\[10mm]

{\large #4}\\[5mm]

{\large National University of Singapore \\
School of Computing}\\[10mm]

{\large \today}\\[10mm]
\end{center}
}

% ----------------------------------------------------------------
% HERE BEGINS THE DOCUMENT
% start with \begin{document}


\usepackage{url}
\usepackage{hyperref}

\hypersetup{
colorlinks=true,
linkcolor=Maroon,
filecolor=Maroon,
urlcolor=Maroon
}
4 changes: 4 additions & 0 deletions src/ec-evaluator/docs/java_intro.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Java is a programming language and computing platform first released by Sun Microsystems in 1995.
It has evolved from humble beginnings to power a large share of today's digital world,
by providing the reliable platform upon which many services and applications are built.
New, innovative products and digital services designed for the future continue to rely on Java, as well.
Loading