Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 11 additions & 9 deletions CLI/CLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,21 @@ int main( int argc, char* argv[] )
std::getline( std::cin, source );
}

// --file F:\Projects\qscript-language\Debug\program.qss
auto exprTypes = QScript::Typer( source );

for ( auto type : exprTypes )
{
if ( type.second != 1024 /* TYPE_NONE */ )
{
std::cout << Compiler::TypeToString( type.first )
<< " -> " << Compiler::TypeToString( type.second ) << std::endl;
}
else
{
std::cout << Compiler::TypeToString( type.first ) << std::endl;
}
//if ( type.second != 1024 /* TYPE_NONE */ )
//{
// std::cout << Compiler::TypeToString( type.first )
// << " -> " << Compiler::TypeToString( type.second ) << std::endl;
//}
//else
//{
// std::cout << Compiler::TypeToString( type.first ) << std::endl;
//}
std::cout << Compiler::TypeToString( *type ) << std::endl;
}
}
EXCEPTION_HANDLING;
Expand Down
10 changes: 5 additions & 5 deletions CLI/CLI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{8FAFE65A-8B53-48EB-94FF-841F5E4AD82C}</ProjectGuid>
<RootNamespace>CLI</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
8 changes: 5 additions & 3 deletions Includes/QScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
#endif
#endif

#include "../Library/Compiler/Types.h"

struct VM_t;

namespace Compiler
{
class BaseNode;
struct Variable_t;

std::string TypeToString( uint32_t type );
bool TypeCheck( uint32_t targetType, uint32_t exprType, bool strict = true );
std::string TypeToString( const Type_t& type );
// bool TypeCheck( Type_t targetType, Type_t exprType );
}

namespace QScript
Expand Down Expand Up @@ -64,7 +66,7 @@ namespace QScript

Chunk_t* AllocChunk();
FunctionObject* Compile( const std::string& source, const Config_t& config = Config_t( true ) );
std::vector< std::pair< uint32_t, uint32_t > > Typer( const std::string& source, const Config_t& config = Config_t( false ) );
std::vector< Compiler::Type_t* > Typer( const std::string& source, const Config_t& config = Config_t( false ) );
std::vector< Compiler::BaseNode* > GenerateAST( const std::string& source );

void FreeChunk( Chunk_t* chunk );
Expand Down
10 changes: 5 additions & 5 deletions LangSrv/LangSrv.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{330A0596-DB49-45E4-AD2C-43A15AA29D21}</ProjectGuid>
<RootNamespace>LangSrv</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
20 changes: 5 additions & 15 deletions Library/Common/Object.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "Value.h"
#include "../Library/Compiler/Types.h"

namespace QScript
{
Expand All @@ -23,13 +24,6 @@ namespace QScript
class FunctionObject : public Object
{
public:
struct Arg_t
{
std::string m_Name;
uint32_t m_Type;
uint32_t m_RetType;
};

FORCEINLINE FunctionObject( const std::string& name, Chunk_t* chunk )
{
m_Type = OT_FUNCTION;
Expand All @@ -40,22 +34,18 @@ namespace QScript

FORCEINLINE void Rename( const std::string& newName ) { m_Name = newName; }
FORCEINLINE const std::string& GetName() const { return m_Name; }
FORCEINLINE int NumArgs() const { return ( int ) m_Arguments.size(); }
FORCEINLINE int NumArgs() const { return m_Arity; }
FORCEINLINE int NumUpvalues() const { return m_NumUpvalues; }
FORCEINLINE Chunk_t* GetChunk() const { return m_Chunk; }
FORCEINLINE const std::vector< Arg_t >& GetArgs() const { return m_Arguments; }

FORCEINLINE void SetUpvalues( int numUpvalues ) { ++m_NumUpvalues; }
FORCEINLINE void AddArgument( const std::string& name, uint32_t type, uint32_t retType )
{
m_Arguments.push_back( Arg_t{ name, type, retType } );
}
FORCEINLINE void SetUpvalues( int numUpvalues ) { ++m_NumUpvalues; }
FORCEINLINE void SetNumArgs( int numArgs ) { m_Arity = numArgs; }

private:
std::string m_Name;
int m_NumUpvalues;
int m_Arity;
Chunk_t* m_Chunk;
std::vector< Arg_t > m_Arguments;
};

class NativeFunctionObject : public Object
Expand Down
Loading