Skip to content

Commit

Permalink
37 passes
Browse files Browse the repository at this point in the history
  • Loading branch information
songmeric committed Mar 22, 2024
1 parent 28ef5d0 commit ca141fc
Show file tree
Hide file tree
Showing 33 changed files with 1,812 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"program": "${workspaceFolder}/bin/c_compiler",
"args": [
"-S",
"compiler_tests/local_var/constant_initialiser",
"compiler_tests/functions/call_constant_external.c",
"-o",
"bin/debug.s",
],
Expand Down
Empty file added diff-2024-03-22-05-42-22
Empty file.
Empty file added diff-2024-03-22-05-43-28
Empty file.
Empty file added diff-2024-03-22-05-45-01
Empty file.
88 changes: 88 additions & 0 deletions diff-2024-03-22-05-45-47
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
--- /tmp/prevrun 2024-03-22 05:45:01.894591000 +0000
+++ /tmp/thisrun 2024-03-22 05:45:47.040460000 +0000
@@ -208,17 +208,17 @@
/workspaces/langproc-cw/bin/output/functions/call_five_args_external/call_five_args_external.s.printed
/workspaces/langproc-cw/bin/output/functions/call_five_args_external/call_five_args_external.linker.stderr.log
/workspaces/langproc-cw/bin/output/functions/call_five_args_external/call_five_args_external.linker.stdout.log

compiler_tests/functions/call_five_args_internal.c
- > Failed to assemble:
+ > Failed to link driver:
/workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.compiler.stderr.log
/workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.compiler.stdout.log
/workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.s
/workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.s.printed
- /workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.assembler.stderr.log
- /workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.assembler.stdout.log
+ /workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.linker.stderr.log
+ /workspaces/langproc-cw/bin/output/functions/call_five_args_internal/call_five_args_internal.linker.stdout.log

compiler_tests/functions/call_identity_external.c
> Failed to link driver:
/workspaces/langproc-cw/bin/output/functions/call_identity_external/call_identity_external.compiler.stderr.log
/workspaces/langproc-cw/bin/output/functions/call_identity_external/call_identity_external.compiler.stdout.log
@@ -275,11 +275,17 @@

compiler_tests/integer/bitwise_and.c
> Pass

compiler_tests/integer/bitwise_or.c
- > Pass
+ > Failed to simulate:
+ /workspaces/langproc-cw/bin/output/integer/bitwise_or/bitwise_or.compiler.stderr.log
+ /workspaces/langproc-cw/bin/output/integer/bitwise_or/bitwise_or.compiler.stdout.log
+ /workspaces/langproc-cw/bin/output/integer/bitwise_or/bitwise_or.s
+ /workspaces/langproc-cw/bin/output/integer/bitwise_or/bitwise_or.s.printed
+ /workspaces/langproc-cw/bin/output/integer/bitwise_or/bitwise_or.simulation.stderr.log
+ /workspaces/langproc-cw/bin/output/integer/bitwise_or/bitwise_or.simulation.stdout.log

compiler_tests/integer/bitwise_xor.c
> Pass

compiler_tests/integer/div.c
@@ -290,11 +296,17 @@

compiler_tests/integer/less_than.c
> Pass

compiler_tests/integer/less_than_equal.c
- > Pass
+ > Failed to simulate:
+ /workspaces/langproc-cw/bin/output/integer/less_than_equal/less_than_equal.compiler.stderr.log
+ /workspaces/langproc-cw/bin/output/integer/less_than_equal/less_than_equal.compiler.stdout.log
+ /workspaces/langproc-cw/bin/output/integer/less_than_equal/less_than_equal.s
+ /workspaces/langproc-cw/bin/output/integer/less_than_equal/less_than_equal.s.printed
+ /workspaces/langproc-cw/bin/output/integer/less_than_equal/less_than_equal.simulation.stderr.log
+ /workspaces/langproc-cw/bin/output/integer/less_than_equal/less_than_equal.simulation.stdout.log

compiler_tests/integer/logical_and.c
> Failed to simulate:
/workspaces/langproc-cw/bin/output/integer/logical_and/logical_and.compiler.stderr.log
/workspaces/langproc-cw/bin/output/integer/logical_and/logical_and.compiler.stdout.log
@@ -308,11 +320,17 @@

compiler_tests/integer/mul.c
> Pass

compiler_tests/integer/sub.c
- > Pass
+ > Failed to simulate:
+ /workspaces/langproc-cw/bin/output/integer/sub/sub.compiler.stderr.log
+ /workspaces/langproc-cw/bin/output/integer/sub/sub.compiler.stdout.log
+ /workspaces/langproc-cw/bin/output/integer/sub/sub.s
+ /workspaces/langproc-cw/bin/output/integer/sub/sub.s.printed
+ /workspaces/langproc-cw/bin/output/integer/sub/sub.simulation.stderr.log
+ /workspaces/langproc-cw/bin/output/integer/sub/sub.simulation.stdout.log

compiler_tests/local_var/constant_initialiser.c
> Pass

compiler_tests/local_var/dual_var.c
@@ -546,6 +564,6 @@
/workspaces/langproc-cw/bin/output/types/unsigned/unsigned.s.printed
/workspaces/langproc-cw/bin/output/types/unsigned/unsigned.assembler.stderr.log
/workspaces/langproc-cw/bin/output/types/unsigned/unsigned.assembler.stdout.log


->> Test Summary: 34 Passed, 52 Failed
+>> Test Summary: 31 Passed, 55 Failed
1 change: 1 addition & 0 deletions include/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "ast_for_statement.hpp"
#include "ast_binary_op.hpp"
#include "ast_parameter_decl.hpp"
#include "ast_function_expr.hpp"

extern Node *ParseAST(std::string file_name);

Expand Down
18 changes: 18 additions & 0 deletions include/ast_argument_expr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef AST_ARGUMENT_EXPR_CPP
#define AST_ARGUMENT_EXPR_CPP

#include "ast_node.hpp"

class ArgumentExpression : public Node
{
private:
Node *arg_;

public:
ArgumentExpression(Node *arg) : arg_(arg){};
~ArgumentExpression(){};
void EmitRISC(std::ostream &stream, Context &context) const override;
void Print(std::ostream &stream) const override;
};

#endif
2 changes: 2 additions & 0 deletions include/ast_binary_op.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class BinaryOp : public Node
void EmitRISC(std::ostream &stream, Context &context) const override;
void Print(std::ostream &stream) const override;

void EmitCall(std::ostream &stream, Context &context) const;

bool IsAssignment() const;
};

Expand Down
5 changes: 5 additions & 0 deletions include/ast_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class Context

int currentFunction{-1};

int currentArgument{-1};

std::vector<Node*> callArgs;

// Stashed by DirectDeclarator
// to hold on to them until the function definition
Node *functionParameters{};
Expand All @@ -77,6 +81,7 @@ class Context
std::string declarationListType;

Variable *FindVariable(std::string const& name);
Function *FindFunction(std::string const &name);
};

#endif
10 changes: 9 additions & 1 deletion include/ast_declaration_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ class DeclarationList : public Node

public:
DeclarationList(Node *type, Node *list)
: type_(type), list_(list){}
: type_(type), list_(list)
{
std::cerr << "Constructing DeclarationList with"
" type=";
type->Print(std::cerr);
std::cerr << " list=";
list->Print(std::cerr);
std::cerr << "\n";
}
~DeclarationList()
{
delete type_;
Expand Down
18 changes: 18 additions & 0 deletions include/ast_function_expr.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef AST_FUNCTION_EXPR_CPP
#define AST_FUNCTION_EXPR_CPP

#include "ast_node.hpp"

class FunctionExpression : public Node
{
private:
Node *fn_;

public:
FunctionExpression(Node *fn) : fn_(fn){};
~FunctionExpression(){};
void EmitRISC(std::ostream &stream, Context &context) const override;
void Print(std::ostream &stream) const override;
};

#endif
5 changes: 5 additions & 0 deletions include/ast_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ enum Operator {

// Indirect (->)
OP_INDIRECT,

// struct member (.)
OP_MEMBER,

// *
OP_DEREFERENCE,

// Shifts
OP_LEFT,
OP_LEFTASSIGN,
Expand Down
7 changes: 5 additions & 2 deletions include/ast_type_specifier.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef AST_TYPE_SPECIFIER
#define AST_TYPE_SPECIFIER

#include <cassert>
#include "ast_node.hpp"

class TypeSpecifier : public Node
Expand All @@ -9,7 +9,10 @@ class TypeSpecifier : public Node
std::string type_;

public:
TypeSpecifier(std::string type) : type_(type){};
TypeSpecifier(std::string type) : type_(type)
{
assert(!type.empty());
}
~TypeSpecifier(){};
void EmitRISC(std::ostream &stream, Context &context) const override;
void Print(std::ostream &stream) const override;
Expand Down
Loading

0 comments on commit ca141fc

Please sign in to comment.