Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
latte
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zygzagZ
latte
Commits
9cab866a
Commit
9cab866a
authored
Dec 31, 2020
by
zygzagZ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP tworzenie asm
parent
3bc2b0ce
Pipeline
#13
failed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
Compiler.cpp
src/Compiler.cpp
+15
-1
Compiler.h
src/Compiler.h
+2
-3
Latte.cpp
src/Latte.cpp
+1
-1
No files found.
src/Compiler.cpp
View file @
9cab866a
#include "Compiler.h"
#include <filesystem>
Compiler
::
Compiler
(
std
::
string
f
)
:
TypeCheck
(),
file
(
f
),
buf
()
{
};
extern
std
::
filesystem
::
path
binaryPath
;
const
std
::
string
Compiler
::
extension
=
"s"
;
void
Compiler
::
externalCommand
(
std
::
filesystem
::
path
lat
)
{
...
...
@@ -20,5 +25,14 @@ void Compiler::externalCommand(std::filesystem::path lat) {
std
::
string
Compiler
::
compile
(
Visitable
*
v
)
{
check
(
v
);
return
"empty
\n
"
;
for
(
auto
i
:
{
"printStr"
,
"printInt"
,
"readInt"
,
"readStr"
,
"error"
,
"exit"
,
"_start"
})
{
buf
<<
".globl "
<<
i
<<
"
\n
"
;
}
buf
<<
"_start:
\n
"
"pushl %%ebp
\n
"
"movl %%esp, %%ebp
\n
"
"call main
\n
"
"pushl %%eax
\n
"
"call exit
\n
"
;
return
buf
.
str
();
}
\ No newline at end of file
src/Compiler.h
View file @
9cab866a
#ifndef COMPILER_HEADER
#define COMPILER_HEADER
/* You might want to change the above name. */
#include "TypeCheck.h"
#include <filesystem>
...
...
@@ -8,8 +7,7 @@
class
Compiler
:
public
TypeCheck
{
public:
Compiler
(
std
::
string
f
)
:
file
(
f
)
{};
Compiler
(
std
::
string
f
);
std
::
string
compile
(
Visitable
*
v
);
static
const
std
::
string
extension
;
...
...
@@ -17,6 +15,7 @@ public:
private:
std
::
filesystem
::
path
file
;
std
::
stringstream
buf
;
// enum State {
// initialized,
// findClasses,
...
...
src/Latte.cpp
View file @
9cab866a
...
...
@@ -75,7 +75,7 @@ int main(int argc, char ** argv)
binaryPath
=
argv
[
0
];
std
::
filesystem
::
path
file
(
filename
?
filename
:
"Latte"
);
try
{
Compiler
c
(
file
);
Compiler
c
(
file
.
string
()
);
std
::
string
out
=
c
.
compile
(
parse_tree
);
if
(
!
filename
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment