Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / Expression.cpp
diff options
context:
space:
mode:
Commit2621d30da58795a19fa2c90978f766e173a8ca2f (patch)
Author
 martin dobrev <martindobrev0@gmail.com>
2018-10-14 15:11:59 +0300
Committer
 martin dobrev <martindobrev0@gmail.com>
2018-10-14 15:11:59 +0300
Filesb85eefde3ea7b5a39a355e7ff13e38debeadb31d /JSImpl/src/Expression.cpp
IPL-2621d30da58795a19fa2c90978f766e173a8ca2f.tar
IPL-2621d30da58795a19fa2c90978f766e173a8ca2f.tar.gz
IPL-2621d30da58795a19fa2c90978f766e173a8ca2f.zip
Parentab6cd5aaa4e1ceb12ade89a4a0c5376092fa8dfb (diff)
Parent47a7a68e2b7ce0b0c1e2bd1097927a91623fbcc5 (diff)
Merge branch 'expressions-rework'
1 files changed, 0 insertions, 277 deletions
-rw-r--r--JSImpl/src/Expression.cpp277
diff --git a/JSImpl/src/Expression.cpp b/JSImpl/src/Expression.cpp
index 22e3da3..b8044e1 100644
--- a/JSImpl/src/Expression.cpp
+++ b/JSImpl/src/Expression.cpp
@@ -1,92 +1,6 @@
#include "Expression.h"
#include <assert.h>
-#include <iostream>
-
-void PrintExpressionMember(ExpressionPtr expr, const char* name, std::ostream& os)
-{
- os << name << ": {" << std::endl;
- expr->Print(os);
- os << "}";
-}
-
-void PrintExpressionMember(IPLVector<ExpressionPtr> exprs, const char* name, std::ostream& os)
-{
- os << name << ": {" << std::endl;
- for (auto& it : exprs)
- {
- it->Print(os);
- os << ",\n";
- }
- os << "}";
-}
-
-BinaryExpression::BinaryExpression(IPLSharedPtr<Expression> exprLeft, IPLSharedPtr<Expression> exprRight, TokenType op)
-: m_Left(exprLeft)
-, m_Right(exprRight)
-, m_Operator(op)
-{}
-
-IPLString BinaryExpression::GetOperatorTypeAsString() const
-{
- // TODO: Implement
- (void)m_Operator;
- return "Binary";
-}
-
-void BinaryExpression::Print(std::ostream& os) const
-{
- os << "{ \n";
- os << " Expression Type: Binary" << std::endl;
- os << " Left expr: ";
- m_Left->Print(os);
-
- os << " Right expr:";
- m_Right->Print(os);
-
- os << " Operator Type: " << GetOperatorTypeAsString();
- os << "\n}\n";
-}
-
-UnaryExpression::UnaryExpression(IPLSharedPtr<Expression> expr, TokenType op, bool suffix)
- : m_Expr(expr)
- , m_Operator(op)
- , m_Suffix(suffix)
-{
-}
-
-void UnaryExpression::Print(std::ostream& os) const
-{
- os << "{ \n";
- os << " Expression Type: Unary" << std::endl;
- os << " Expression: ";
- m_Expr->Print(os);
-
- os << " Operator Type: " << GetOperatorTypeAsString() << std::endl;
- os << " Suffix Type: " << (m_Suffix ? "true" : "false") << std::endl;
- os << "\n}\n";
-}
-
-IPLString UnaryExpression::GetOperatorTypeAsString() const
-{
- switch (m_Operator)
- {
- case TokenType::Delete: return "delete";
- case TokenType::MinusMinus: return "--";
- case TokenType::PlusPlus: return "++";
- case TokenType::Void: return "void";
- case TokenType::Typeof: return "void";
- case TokenType::Plus: return "+";
- case TokenType::Minus: return "-";
- case TokenType::BitwiseNot: return "~";
- case TokenType::Bang: return "!";
- default:
- break;
- }
- // TODO: Implement
- return "Unary";
-}
-
LiteralExpression::LiteralExpression(double v)
:m_Type(LiteralType::Number)
, m_NumValue(v)
@@ -117,194 +31,3 @@ LiteralExpression::LiteralExpression(TokenType type)
assert(false);
}
}
-
-void LiteralExpression::Print(std::ostream& os) const
-{
- os << "{ \n";
- os << " Expression Type: Unary" << std::endl;
- switch (m_Type)
- {
- case LiteralType::Number:
- os << " Literal Type: Number" << std::endl;
- os << " Literal value: " << m_NumValue << std::endl;
- break;
- case LiteralType::String:
- os << " Literal Type: String" << std::endl;
- os << " Literal value: " << m_StringValue << std::endl;
- break;
- case LiteralType::Boolean:
- os << " Literal Type: Boolean" << std::endl;
- os << " Literal value: " << m_BooleanValue << std::endl;
- break;
- case LiteralType::Null:
- os << " Literal Type: Null" << std::endl;
- os << " Literal value: null" << std::endl;
- case LiteralType::Undefined:
- os << " Literal Type: Undefined" << std::endl;
- os << " Literal value: undefined" << std::endl;
- break;
- default:
- break;
- }
-
- os << "\n}\n";
-}
-
-IdentifierExpression::IdentifierExpression(IPLString& name)
- : m_Name(name)
-{
-}
-
-void IdentifierExpression::Print(std::ostream& os) const
-{
- os << "{ \n";
- os << " Expression Type: Identifier" << std::endl;
- os << "Identifier name: " << m_Name << std::endl;
- os << "\n}\n";
-}
-
-void ListExpression::Print(std::ostream& os) const
-{
- os << "{ \n";
- os << " Expression Type: List" << std::endl;
- for (auto& e : m_Values)
- {
- e->Print(os);
- }
- os << "\n}\n";
-}
-
-void VariableDefinitionExpression::Print(std::ostream& os) const
-{
- os << "{ \n";
- os << " Expression Type: VariableDefinition" << std::endl;
- os << "Identifier name: " << m_Name << std::endl;
- m_Value->Print(os);
- os << "\n}\n";
-}
-
-void BlockStatement::Print(std::ostream& os) const
-{
- os << "{ \n";
- os << " Expression Type: BlockStatement" << std::endl;
- for (auto& e : m_Values)
- {
- e->Print(os);
- }
- os << "\n}\n";
-}
-
-LabeledStatement::LabeledStatement(IPLString& identifier, ExpressionPtr statement)
- : m_Identifier(identifier)
- , m_Statement(statement)
-{
-}
-
-void LabeledStatement::Print(std::ostream& os) const
-{
- os << "{ LabeledStatement Not implemented yet !!}";
-}
-
-IfStatement::IfStatement(ExpressionPtr cond, ExpressionPtr ifStatement, ExpressionPtr elseStatement)
- : m_Condition(cond)
- , m_IfStatement(ifStatement)
- , m_ElseStatement(elseStatement)
-{
-}
-
-void IfStatement::Print(std::ostream& os) const
-{
- os << "{ IfStatement Not implemented yet !!}";
-}
-
-SwitchStatement::SwitchStatement(ExpressionPtr cond, IPLVector<Case>& cases, ExpressionPtr defaultCase)
- : m_Condition(cond)
- , m_Cases(cases)
- , m_DefaultCase(defaultCase)
-{
-}
-
-void SwitchStatement::Print(std::ostream& os) const
-{
- os << "{ SwitchStatement Not implemented yet !!}";
-}
-
-WhileStatement::WhileStatement(ExpressionPtr cond, ExpressionPtr body, bool doWhile)
- : m_Condition(cond)
- , m_Body(body)
- , m_DoWhile(doWhile)
-{
-}
-
-
-void WhileStatement::Print(std::ostream& os) const
-{
- (void)(m_DoWhile);
- os << "{ WhileStatement Not implemented yet !!}";
-}
-
-ForStatement::ForStatement(ExpressionPtr initialization, ExpressionPtr cond, ExpressionPtr iteration, ExpressionPtr body)
- : m_Initialization(initialization)
- , m_Condition(cond)
- , m_Iteration(iteration)
- , m_Body(body)
-{
-}
-
-void ForStatement::Print(std::ostream& os) const
-{
- os << "{ Expression Type: ForStatement " << std::endl;
- os << "{ Initialization:" << std::endl;
- m_Initialization->Print(os);
- os << "}" << std::endl;
- os << "{ Condition:" << std::endl;
- m_Condition->Print(os);
- os << "}" << std::endl;
- os << "{ Iteration:" << std::endl;
- m_Condition->Print(os);
- os << "}" << std::endl;
- os << "{ Body:" << std::endl;
- m_Body->Print(os);
- os << "}" << std::endl;
-}
-
-
-FunctionDeclaration::FunctionDeclaration(IPLString& functionName, IPLVector<IPLString>& argumentsIdentifiers, ExpressionPtr body)
- : m_Name(functionName)
- , m_ArgumentsIdentifiers(argumentsIdentifiers)
- , m_Body(body)
-{
-}
-
-void FunctionDeclaration::Print(std::ostream& os) const
-{
- os << "{ Expression Type: FunctionDeclaration " << std::endl;
- os << "{ Function name: " << m_Name << std::endl;
- os << "{ Function parameters: " << std::endl;
- os << "{ " << std::endl;
- for (auto it : m_ArgumentsIdentifiers)
- {
- os << it;
- }
- os << "}" << std::endl;
- os << "{ Function body:" << std::endl;
- m_Body->Print(os);
- os << "}" << std::endl;
- os << "}" << std::endl;
-}
-
-
-void TopStatements::Print(std::ostream& os) const
-{
- os << "{ Expression Type: TopStatements " << std::endl;;
- for (auto it : m_Values)
- {
- it->Print(os);
- }
- os << "}";
-}
-
-void EmptyExpression::Print(std::ostream& os) const
-{
- os << "{ EmptyExpression }";
-}