I began implementing function functionality and I apply some changes to
whole design.functions
parent
93a63d43e9
commit
39794ea711
|
@ -1,139 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496" name="Debug" parent="cdt.managedbuild.config.gnu.cross.exe.debug">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.2045041315" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1733237476" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/Sencha-lang/Debug}" id="cdt.managedbuild.builder.gnu.cross.2091580062" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1055356392" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.758256537" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.1319397326" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.809384772" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.495732557" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.793014755" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1513381051" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.other.other.335578218" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" value="-c -fmessage-length=0 -std=gnu++0x " valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.859439950" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.693029150" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1545256246" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1240442083" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.973026492" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1898223694" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.415327363" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="AST|Tests" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="AST"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="Tests"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505" name="Release" parent="cdt.managedbuild.config.gnu.cross.exe.release">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.release.1985450505." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cross.exe.release.1226114014" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.release">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.676474921" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
|
||||
<builder buildPath="${workspace_loc:/Sencha-lang/Release}" id="cdt.managedbuild.builder.gnu.cross.23375219" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.671993191" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.option.optimization.level.1104799874" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.debugging.level.1423670337" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1507898701" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.compiler.938543294" name="Cross G++ Compiler" superClass="cdt.managedbuild.tool.gnu.cross.cpp.compiler">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.491096180" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.debugging.level.1816198684" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.599623873" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1203418436" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.860949532" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.124143498" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.archiver.1698336651" name="Cross GCC Archiver" superClass="cdt.managedbuild.tool.gnu.cross.archiver"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.assembler.1350015407" name="Cross GCC Assembler" superClass="cdt.managedbuild.tool.gnu.cross.assembler">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.949134942" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="Sencha-lang.cdt.managedbuild.target.gnu.cross.exe.1970449863" name="Executable" projectType="cdt.managedbuild.target.gnu.cross.exe"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Release">
|
||||
<resource resourceType="PROJECT" workspacePath="/Sencha-lang"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Debug">
|
||||
<resource resourceType="PROJECT" workspacePath="/Sencha-lang"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1985450505;cdt.managedbuild.config.gnu.cross.exe.release.1985450505.;cdt.managedbuild.tool.gnu.cross.c.compiler.671993191;cdt.managedbuild.tool.gnu.c.compiler.input.1507898701">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.release.1985450505;cdt.managedbuild.config.gnu.cross.exe.release.1985450505.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.938543294;cdt.managedbuild.tool.gnu.cpp.compiler.input.599623873">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496;cdt.managedbuild.config.gnu.cross.exe.debug.1544392496.;cdt.managedbuild.tool.gnu.cross.c.compiler.1055356392;cdt.managedbuild.tool.gnu.c.compiler.input.809384772">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cross.exe.debug.1544392496;cdt.managedbuild.config.gnu.cross.exe.debug.1544392496.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.495732557;cdt.managedbuild.tool.gnu.cpp.compiler.input.859439950">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -g -v -dD "${plugin_state_location}/specs.cpp"" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
</cproject>
|
|
@ -9,7 +9,7 @@
|
|||
#define ASTNODE_H_
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "SenchaObject.h"
|
||||
#include "../Elements/SenchaObject.h"
|
||||
#include "../Visitor.h"
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ void Assignment::execute_quietly()
|
|||
}
|
||||
}
|
||||
|
||||
Assignment::Assignment(Context * context, std::string name, ASTExpression * left, ASTExpression * right)
|
||||
Assignment::Assignment(ContextManager * context, std::string name, ASTExpression * left, ASTExpression * right)
|
||||
{
|
||||
this->context = context;
|
||||
this->type = "Assignment";
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define ASSIGNMENT_H_
|
||||
#include <string>
|
||||
#include "ASTExpression.h"
|
||||
#include "../Context.h"
|
||||
#include "../ContextManager.h"
|
||||
/**
|
||||
* Assignment is an abstraction of assignment.
|
||||
* It is different from i.e BasicExpression so that it change value of the lvalue
|
||||
|
@ -22,14 +22,14 @@
|
|||
*/
|
||||
class Assignment : public ASTExpression {
|
||||
public:
|
||||
Context * context;
|
||||
ContextManager * context;
|
||||
|
||||
std::string name;
|
||||
|
||||
SenchaObject evaluate();
|
||||
void execute();
|
||||
void execute_quietly();
|
||||
Assignment(Context * context, std::string name, ASTExpression * left, ASTExpression * right);
|
||||
Assignment(ContextManager * context, std::string name, ASTExpression * left, ASTExpression * right);
|
||||
virtual ~Assignment();
|
||||
};
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define CONSTANTEXPRESSION_H_
|
||||
#include "ASTExpression.h"
|
||||
#include <iostream>
|
||||
#include "../Context.h"
|
||||
|
||||
|
||||
/**
|
||||
* ConstantExpression class is used to store complex expression, which are actually
|
||||
|
|
|
@ -27,7 +27,7 @@ void DeclarationStatement::add_right_value(ASTExpression * right)
|
|||
children[0] = right;
|
||||
}
|
||||
|
||||
DeclarationStatement::DeclarationStatement(Context * context)
|
||||
DeclarationStatement::DeclarationStatement(ContextManager * context)
|
||||
{
|
||||
this->context = context;
|
||||
is_function = false;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "ASTStatement.h"
|
||||
#include "ASTExpression.h"
|
||||
#include "ConstantExpression.h"
|
||||
#include "../Context.h"
|
||||
#include "../ContextManager.h"
|
||||
|
||||
/**
|
||||
* DeclarationStatement is abstraction of declaration/definition
|
||||
|
@ -21,14 +21,14 @@
|
|||
class DeclarationStatement: public ASTStatement {
|
||||
public:
|
||||
std::string name;
|
||||
Context * context;
|
||||
ContextManager * context;
|
||||
SenchaObject right_value;
|
||||
ASTStatement * body;
|
||||
std::vector<std::string> arguments;
|
||||
bool is_function;
|
||||
|
||||
void add_right_value(ASTExpression * right);
|
||||
DeclarationStatement(Context * context);
|
||||
DeclarationStatement(ContextManager * context);
|
||||
void add_name(std::string);
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "PostfixExpression.h"
|
||||
|
||||
PostfixExpression::PostfixExpression(std::string name, Context * context):
|
||||
PostfixExpression::PostfixExpression(std::string name, ContextManager * context):
|
||||
name(name), context(context), native(false)
|
||||
{
|
||||
type= "PostfixExpression";
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define POSTFIXEXPRESSION_H_
|
||||
#include "ASTExpression.h"
|
||||
#include "ASTStatement.h"
|
||||
#include "../Context.h"
|
||||
#include "../ContextManager.h"
|
||||
|
||||
/**
|
||||
* PostfixExpression is in current implementation an abstraction
|
||||
|
@ -18,7 +18,7 @@
|
|||
class PostfixExpression : public ASTExpression {
|
||||
public:
|
||||
std::string name;
|
||||
Context * context;
|
||||
ContextManager * context;
|
||||
bool native;
|
||||
std::vector<ASTExpression *> arguments;
|
||||
void add_argument(ASTExpression * expression);
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
virtual void execute();
|
||||
virtual void execute_quietly(){ execute();};
|
||||
|
||||
PostfixExpression( std::string name, Context * context);
|
||||
PostfixExpression( std::string name, ContextManager * context);
|
||||
virtual ~PostfixExpression();
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "VariableExpression.h"
|
||||
|
||||
VariableExpression::VariableExpression(std::string name, Context * context) {
|
||||
VariableExpression::VariableExpression(std::string name, ContextManager * context) {
|
||||
this->name = name;
|
||||
this->context = context;
|
||||
this->type = "VariableExpression";
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define VARIABLEEXPRESSION_H_
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "../Context.h"
|
||||
#include "../ContextManager.h"
|
||||
#include "ASTExpression.h"
|
||||
|
||||
/**
|
||||
|
@ -19,9 +19,9 @@
|
|||
class VariableExpression: public ASTExpression {
|
||||
public:
|
||||
VariableExpression();
|
||||
VariableExpression(std::string name, Context * context);
|
||||
VariableExpression(std::string name, ContextManager * context);
|
||||
|
||||
Context * context;
|
||||
ContextManager * context;
|
||||
std::string name;
|
||||
|
||||
void execute();
|
||||
|
|
|
@ -5,21 +5,21 @@
|
|||
* Author: attero
|
||||
*/
|
||||
|
||||
#include "Context.h"
|
||||
#include "ContextManager.h"
|
||||
|
||||
Context::Context() {
|
||||
ContextManager::ContextManager() {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
Context::~Context() {
|
||||
ContextManager::~ContextManager() {
|
||||
}
|
||||
|
||||
void Context::register_function(std::string name, PointerToNativeFunction f)
|
||||
void ContextManager::register_function(std::string name, PointerToNativeFunction f)
|
||||
{
|
||||
registered_functions[name] = f;
|
||||
}
|
||||
|
||||
SenchaObject Context::execute_native_function(std::string name, std::vector<ASTExpression *> arguments)
|
||||
SenchaObject ContextManager::execute_native_function(std::string name, std::vector<ASTExpression *> arguments)
|
||||
{
|
||||
SenchaObject result;
|
||||
if(registered_functions.count(name) == 1)
|
||||
|
@ -27,7 +27,7 @@ SenchaObject Context::execute_native_function(std::string name, std::vector<ASTE
|
|||
return result;
|
||||
}
|
||||
|
||||
ObjectIndex Context::add_to_store(SenchaObject & object)
|
||||
ObjectIndex ContextManager::add_to_store(SenchaObject & object)
|
||||
{
|
||||
index++;
|
||||
object_store[index] = object;
|
||||
|
@ -35,17 +35,17 @@ ObjectIndex Context::add_to_store(SenchaObject & object)
|
|||
return index;
|
||||
}
|
||||
|
||||
SenchaObject Context::get_from_store(ObjectIndex index)
|
||||
SenchaObject ContextManager::get_from_store(ObjectIndex index)
|
||||
{
|
||||
return object_store[index];
|
||||
}
|
||||
|
||||
void Context::add(std::string name, SenchaObject object)
|
||||
void ContextManager::add(std::string name, SenchaObject object)
|
||||
{
|
||||
interpreter_context[name] = add_to_store(object);
|
||||
}
|
||||
|
||||
void Context::set(std::string name, SenchaObject object)
|
||||
void ContextManager::set(std::string name, SenchaObject object)
|
||||
{
|
||||
if(interpreter_context[name] != 0)
|
||||
{
|
||||
|
@ -58,12 +58,12 @@ void Context::set(std::string name, SenchaObject object)
|
|||
}
|
||||
}
|
||||
|
||||
SenchaObject Context::get(std::string name)
|
||||
SenchaObject ContextManager::get(std::string name)
|
||||
{
|
||||
return get_from_store(interpreter_context[name]);
|
||||
}
|
||||
|
||||
std::string Context::debug() {
|
||||
std::string ContextManager::debug() {
|
||||
std::string debug_note = "";
|
||||
|
||||
for( auto iter = this->interpreter_context.begin(); iter != this->interpreter_context.end(); iter++)
|
|
@ -11,16 +11,16 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "AST/SenchaObject.h"
|
||||
#include "Elements/SenchaObject.h"
|
||||
#include "AST/ASTExpression.h"
|
||||
|
||||
|
||||
typedef unsigned long ObjectIndex;
|
||||
typedef unsigned long FunctionIndex;
|
||||
|
||||
class Context {
|
||||
class ContextManager {
|
||||
public:
|
||||
Context();
|
||||
ContextManager();
|
||||
typedef unsigned long ObjectIndex;
|
||||
ObjectIndex index;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
ExecutionContext global_context;
|
||||
std::map<FunctionIndex , ExecutionContext *> function_contexts;
|
||||
virtual ~Context();
|
||||
virtual ~ContextManager();
|
||||
};
|
||||
|
||||
#endif /* CONTEXT_H_ */
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Element.cpp
|
||||
*
|
||||
* Created on: Dec 30, 2012
|
||||
* Author: att
|
||||
*/
|
||||
|
||||
#include "Element.h"
|
||||
|
||||
Element::Element()
|
||||
{
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
Element::~Element()
|
||||
{
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Element.h
|
||||
*
|
||||
* Created on: Dec 30, 2012
|
||||
* Author: att
|
||||
*/
|
||||
|
||||
#ifndef ELEMENT_H_
|
||||
#define ELEMENT_H_
|
||||
|
||||
class Element
|
||||
{
|
||||
public:
|
||||
Element();
|
||||
virtual ~Element();
|
||||
};
|
||||
|
||||
#endif /* ELEMENT_H_ */
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* SenchaFunction.cpp
|
||||
*
|
||||
* Created on: Dec 30, 2012
|
||||
* Author: att
|
||||
*/
|
||||
|
||||
#include "SenchaFunction.h"
|
||||
|
||||
SenchaFunction::SenchaFunction(std::string name, std::vector<std::string> names_of_arguments, ASTNode * body, Context * context)
|
||||
: name(name), names_of_arguments(names_of_arguments), body(body), context(context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SenchaFunction::~SenchaFunction() {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* SenchaFunction.h
|
||||
*
|
||||
* Created on: Dec 30, 2012
|
||||
* Author: att
|
||||
*/
|
||||
|
||||
#ifndef SENCHAFUNCTION_H_
|
||||
#define SENCHAFUNCTION_H_
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <SenchaObject.h>
|
||||
#include "Element.h"
|
||||
#include "../Utils/to_string.h"
|
||||
#include "../Context.h"
|
||||
#include "../AST/ASTNode.h"
|
||||
|
||||
|
||||
class SenchaFunction : public Element
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
std::vector<std::string> names_of_arguments;
|
||||
ASTNode * body;
|
||||
Context * context;
|
||||
|
||||
SenchaFunction(std::string name, std::vector<std::string> names_of_arguments, ASTNode * body, Context * context);
|
||||
virtual ~SenchaFunction();
|
||||
};
|
||||
|
||||
#endif /* SENCHAFUNCTION_H_ */
|
|
@ -25,6 +25,48 @@ bool SenchaObject::is_true()
|
|||
else return true;
|
||||
|
||||
}
|
||||
|
||||
void SenchaObject::set_value(std::string text)
|
||||
{
|
||||
if(text[0] == '\"' && text[text.size()-1] == '\"')
|
||||
{
|
||||
this->text = text.substr(1, text.size()-2);
|
||||
type = string_literal;
|
||||
}
|
||||
}
|
||||
|
||||
void SenchaObject::set_new_string(std::string text)
|
||||
{
|
||||
this->text = text;
|
||||
type = string_literal;
|
||||
}
|
||||
|
||||
void SenchaObject::set_null_value()
|
||||
{
|
||||
this->type = null;
|
||||
this->integer = 0;
|
||||
this->number = 0;
|
||||
this->text = "";
|
||||
}
|
||||
|
||||
void SenchaObject::set_value(int integer)
|
||||
{
|
||||
this->integer = integer;
|
||||
type = integer_number;
|
||||
}
|
||||
|
||||
void SenchaObject::set_value(double number)
|
||||
{
|
||||
this->number = number;
|
||||
type = float_number;
|
||||
}
|
||||
|
||||
void SenchaObject::set_value(bool logic)
|
||||
{
|
||||
this->truthy = logic;
|
||||
type = boolean;
|
||||
}
|
||||
|
||||
std::string SenchaObject::repr()
|
||||
{
|
||||
std::string representation = "";
|
|
@ -9,8 +9,10 @@
|
|||
#define SENCHAOBJECT_H_
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "to_string.h"
|
||||
class SenchaObject {
|
||||
#include "../Utils/to_string.h"
|
||||
#include "Element.h"
|
||||
|
||||
class SenchaObject : public Element {
|
||||
|
||||
public:
|
||||
typedef enum {
|
||||
|
@ -35,46 +37,12 @@ public:
|
|||
int integer;
|
||||
double number;
|
||||
|
||||
void set_value(std::string text)
|
||||
{
|
||||
if(text[0] == '\"' && text[text.size()-1] == '\"')
|
||||
{
|
||||
this->text = text.substr(1, text.size()-2);
|
||||
type = string_literal;
|
||||
}
|
||||
}
|
||||
|
||||
void set_new_string(std::string text)
|
||||
{
|
||||
this->text = text;
|
||||
type = string_literal;
|
||||
}
|
||||
|
||||
void set_null_value()
|
||||
{
|
||||
this->type = null;
|
||||
this->integer = 0;
|
||||
this->number = 0;
|
||||
this->text = "";
|
||||
}
|
||||
|
||||
void set_value(int integer)
|
||||
{
|
||||
this->integer = integer;
|
||||
type = integer_number;
|
||||
}
|
||||
|
||||
void set_value(double number)
|
||||
{
|
||||
this->number = number;
|
||||
type = float_number;
|
||||
}
|
||||
|
||||
void set_value(bool logic)
|
||||
{
|
||||
this->truthy = logic;
|
||||
type = boolean;
|
||||
}
|
||||
void set_value(std::string text);
|
||||
void set_new_string(std::string text);
|
||||
void set_null_value();
|
||||
void set_value(int integer);
|
||||
void set_value(double number);
|
||||
void set_value(bool logic);
|
||||
|
||||
SenchaObject();
|
||||
SenchaObject(int integer) { set_value(integer); }
|
||||
|
@ -84,9 +52,9 @@ public:
|
|||
|
||||
|
||||
virtual SenchaObject operator< (const SenchaObject& right)const;
|
||||
virtual SenchaObject operator> (const SenchaObject& right)const;
|
||||
virtual SenchaObject operator<= (const SenchaObject& right)const;
|
||||
virtual SenchaObject operator>= (const SenchaObject& right)const;
|
||||
virtual SenchaObject operator> (const SenchaObject& right)const;
|
||||
virtual SenchaObject operator<= (const SenchaObject& right)const;
|
||||
virtual SenchaObject operator>= (const SenchaObject& right)const;
|
||||
virtual SenchaObject operator+(const SenchaObject& right)const;
|
||||
virtual SenchaObject operator-(const SenchaObject& right)const;
|
||||
virtual SenchaObject operator*(const SenchaObject& right)const;
|
|
@ -1,7 +1,7 @@
|
|||
#include "Parser.h"
|
||||
#include "iostream"
|
||||
|
||||
Parser::Parser(Context * context)
|
||||
Parser::Parser(ContextManager * context)
|
||||
{
|
||||
this->context = context;
|
||||
error_message = "***ERRORS DURING PARSING***\n";
|
||||
|
@ -25,6 +25,7 @@ void Parser::erase_all()
|
|||
delete program;
|
||||
program = new ProgramNode();
|
||||
}
|
||||
|
||||
string Parser::show_tokens()
|
||||
{
|
||||
string tokens = "";
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include "Token.h"
|
||||
#include "Context.h"
|
||||
#include "ContextManager.h"
|
||||
#include "AST/AllTypesOfASTNodes.h"
|
||||
#include "AST/AST.h"
|
||||
|
||||
|
@ -13,8 +13,8 @@ using namespace std;
|
|||
class Parser
|
||||
{
|
||||
public:
|
||||
Parser(Context * context);
|
||||
Context * context;
|
||||
Parser(ContextManager * context);
|
||||
ContextManager * context;
|
||||
|
||||
virtual ~Parser();
|
||||
void interpret();
|
||||
|
|
|
@ -21,7 +21,7 @@ std::string TestParser::test_parsing_and_evaluating_logical_expressions()
|
|||
std::string test_report = "";
|
||||
std::vector<InputOutputPair> logical_inputs = prepare_logical_input();
|
||||
Lexer lexer;
|
||||
Context context;
|
||||
ContextManager context;
|
||||
Parser parser(&context);
|
||||
for(auto logical_case : logical_inputs)
|
||||
{
|
||||
|
@ -35,6 +35,17 @@ std::string TestParser::test_parsing_and_evaluating_logical_expressions()
|
|||
return test_report;
|
||||
}
|
||||
|
||||
std::string TestParser::test_adding_new_function()
|
||||
{
|
||||
std::string test_report = "";
|
||||
std::string function_declaration =+ "def print_hello(how_many_times) {";
|
||||
function_declaration =+ " repeat(how_many_times) { print(\"Hello\");}";
|
||||
|
||||
|
||||
return test_report;
|
||||
}
|
||||
|
||||
|
||||
std::vector<TestParser::InputOutputPair> TestParser::prepare_logical_input()
|
||||
{
|
||||
std::vector<InputOutputPair> logical_inputs;
|
||||
|
@ -52,6 +63,7 @@ std::vector<TestParser::InputOutputPair> TestParser::prepare_logical_input()
|
|||
return logical_inputs;
|
||||
}
|
||||
|
||||
|
||||
std::string TestParser::all_tests()
|
||||
{
|
||||
std::string test_report = "";
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
typedef std::pair<std::string, bool> InputOutputPair;
|
||||
private:
|
||||
std::string test_parsing_and_evaluating_logical_expressions();
|
||||
|
||||
std::string test_adding_new_function();
|
||||
std::vector<InputOutputPair> prepare_logical_input();
|
||||
|
||||
virtual std::string all_tests();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "Lexer.h"
|
||||
#include "Parser.h"
|
||||
#include "Tests/TestLexer.h"
|
||||
#include "Context.h"
|
||||
#include "ContextManager.h"
|
||||
#include "ASTInspector.h"
|
||||
#include "Tests/tests.h"
|
||||
#include <unistd.h>
|
||||
|
@ -145,7 +145,7 @@ void interactive()
|
|||
{
|
||||
Lexer lexer;
|
||||
|
||||
Context context;
|
||||
ContextManager context;
|
||||
context.register_function("print", print);
|
||||
context.register_function("sin", s_sin);
|
||||
context.register_function("cos", s_cos);
|
||||
|
@ -174,16 +174,11 @@ void interactive()
|
|||
if(level_of_depth == 0) {
|
||||
parser.interpret();
|
||||
parser.program->execute_last();
|
||||
//cout << parser.error_message << endl;
|
||||
//cout << parser.show_tokens() << endl;
|
||||
inspector.visit(parser.program);
|
||||
|
||||
//cout << parser.context->debug();
|
||||
cout << inspector.get_report();
|
||||
inspector.forget_everything();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -204,7 +199,7 @@ int main(int argc, char *argv[])
|
|||
else {
|
||||
auto name = argument1;
|
||||
Lexer lexer;
|
||||
Context context;
|
||||
ContextManager context;
|
||||
context.register_function("print", print);
|
||||
context.register_function("sin", s_sin);
|
||||
context.register_function("cos", s_cos);
|
||||
|
|
Loading…
Reference in New Issue