diff options
65 files changed, 1335 insertions, 0 deletions
diff --git a/doc/BNF.txt b/doc/BNF.txt new file mode 100644 index 0000000..139597f --- /dev/null +++ b/doc/BNF.txt @@ -0,0 +1,2 @@ + + diff --git a/modules/gl/gl.qs b/modules/gl/gl.qs new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/modules/gl/gl.qs diff --git a/modules/gl/gl.qs.dll b/modules/gl/gl.qs.dll new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/modules/gl/gl.qs.dll diff --git a/modules/gl/init.qs b/modules/gl/init.qs new file mode 100644 index 0000000..8d54a93 --- /dev/null +++ b/modules/gl/init.qs @@ -0,0 +1,3 @@ + +import gl; + diff --git a/modules/math3d/vector3.qs b/modules/math3d/vector3.qs new file mode 100644 index 0000000..2401b0e --- /dev/null +++ b/modules/math3d/vector3.qs @@ -0,0 +1,34 @@ +import math for Math; + +class Vector3 { + static one = new Vector3(1,1,1); + static zero = new Vector3(0,0,0); + static front = ne Vector3(0,0,1); + static up = new Vector3(0,1,0); + static right = new Vector3(1,0,0); + + func init(x, y, z) { + self.x = x; + self.y = y; + self.z = z; + } + + func length() { + return Math.sqrt(self.x^2 + self.y^2 + self.z^2); + } + + static func lerp(v1, v2, t) { + + } + + static func slerp(v1, v2, t) { + + } + +} + +/* +var v = new Vector3(1,1,1); + + +*/
\ No newline at end of file diff --git a/modules/std/base64.qs b/modules/std/base64.qs new file mode 100644 index 0000000..d14dbbc --- /dev/null +++ b/modules/std/base64.qs @@ -0,0 +1,15 @@ +class Base64 { + static func encode(str) { + + } + + static func decode(str) { + + } +} + +/* +var base64 = Base64.encode("asasdadqweqwe12312"); + + +*/
\ No newline at end of file diff --git a/modules/std/event.qs b/modules/std/event.qs new file mode 100644 index 0000000..d4f2a10 --- /dev/null +++ b/modules/std/event.qs @@ -0,0 +1,42 @@ +import debug for debug; + +class event { + func init() { + self._func = []; // callback functions list + } + + func clear() { + self._func.clear(); + } + + func += (fn) { + if(typeof(fn) != "function") + debug.assert("wrong type"); + if(!self._func.contains(fn)) + self._func.push(fn); + else + debug.logError("ÒѾ´æÔÚÕâ¸ö·½·¨"); + } + + func -= (fn) { + if(typeof(fn) != "function") + debug.assert("wrong type"); + self._func.remove(fn); + } + + func () (...){ + foreach(var fn in self._func) { + fn(...); + } + } +} + +/* +var Say = new event(); +Say += func(str) { + io.print(str); +} +Say("hi"); +Say.clear(); + +*/
\ No newline at end of file diff --git a/modules/std/init.qs b/modules/std/init.qs new file mode 100644 index 0000000..fd4327d --- /dev/null +++ b/modules/std/init.qs @@ -0,0 +1,2 @@ +import "base64.qs" ; + diff --git a/modules/std/singleton.qs b/modules/std/singleton.qs new file mode 100644 index 0000000..afade4b --- /dev/null +++ b/modules/std/singleton.qs @@ -0,0 +1,23 @@ + +class Singleton { + static func get() { + if( type._instance == null ) { + type._instance = new type(); + } + return type._instance; + } +} + +/* +Usage: + +class SoundManager is Singleton { + func init() { + + } +} + +var mgr = SoundManager.get(); + +//type is upvalue\preset value, like self +*/
\ No newline at end of file diff --git a/modules/std/stack.qs b/modules/std/stack.qs new file mode 100644 index 0000000..4151e39 --- /dev/null +++ b/modules/std/stack.qs @@ -0,0 +1,20 @@ +class Stack { + func init() { + self._stack = []; + } + + func push(element) { + self._stack.push(element); + } + + func pop() { + self._stack.pop(); + } + + func size() { + + } +} + + + diff --git a/noob.sln b/noob.sln new file mode 100644 index 0000000..4a44243 --- /dev/null +++ b/noob.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "noob", "noob\noob.vcxproj", "{52C647DA-51A2-49C9-8B66-ADBF48D4000F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Debug|x64.ActiveCfg = Debug|x64 + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Debug|x64.Build.0 = Debug|x64 + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Debug|x86.ActiveCfg = Debug|Win32 + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Debug|x86.Build.0 = Debug|Win32 + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Release|x64.ActiveCfg = Release|x64 + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Release|x64.Build.0 = Release|x64 + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Release|x86.ActiveCfg = Release|Win32 + {52C647DA-51A2-49C9-8B66-ADBF48D4000F}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5B1D9A61-E77C-41DD-9B49-0C20DD825E9A} + EndGlobalSection +EndGlobal diff --git a/noob/noob.vcxproj b/noob/noob.vcxproj new file mode 100644 index 0000000..5e0103a --- /dev/null +++ b/noob/noob.vcxproj @@ -0,0 +1,177 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\src\nb_common.h" /> + <ClInclude Include="..\src\nb_config.h" /> + <ClInclude Include="..\src\nb_debug.h" /> + <ClInclude Include="..\src\nb_dump.h" /> + <ClInclude Include="..\src\nb_gc.h" /> + <ClInclude Include="..\src\nb_lexer.h" /> + <ClInclude Include="..\src\nb_libio.h" /> + <ClInclude Include="..\src\nb_libmath.h" /> + <ClInclude Include="..\src\nb_libos.h" /> + <ClInclude Include="..\src\nb_mem.h" /> + <ClInclude Include="..\src\nb_module.h" /> + <ClInclude Include="..\src\nb_obj.h" /> + <ClInclude Include="..\src\nb_opcode.h" /> + <ClInclude Include="..\src\nb_parser.h" /> + <ClInclude Include="..\src\nb_preproc.h" /> + <ClInclude Include="..\src\nb_string.h" /> + <ClInclude Include="..\src\nb_token.h" /> + <ClInclude Include="..\src\nb_undump.h" /> + <ClInclude Include="..\src\nb_util.h" /> + <ClInclude Include="..\src\nb_value.h" /> + <ClInclude Include="..\src\nb_vm.h" /> + <ClInclude Include="..\src\noob.h" /> + <ClInclude Include="..\src\noob.hpp" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\src\nb_debug.c" /> + <ClCompile Include="..\src\nb_dump.c" /> + <ClCompile Include="..\src\nb_gc.c" /> + <ClCompile Include="..\src\nb_hashset.c" /> + <ClCompile Include="..\src\nb_lexer.c" /> + <ClCompile Include="..\src\nb_libio.c" /> + <ClCompile Include="..\src\nb_libmath.c" /> + <ClCompile Include="..\src\nb_libos.c" /> + <ClCompile Include="..\src\nb_list.c" /> + <ClCompile Include="..\src\nb_map.c" /> + <ClCompile Include="..\src\nb_mem.c" /> + <ClCompile Include="..\src\nb_module.c" /> + <ClCompile Include="..\src\nb_obj.c" /> + <ClCompile Include="..\src\nb_parser.c" /> + <ClCompile Include="..\src\nb_preproc.c" /> + <ClCompile Include="..\src\nb_string.c" /> + <ClCompile Include="..\src\nb_undump.c" /> + <ClCompile Include="..\src\nb_util.c" /> + <ClCompile Include="..\src\nb_value.c" /> + <ClCompile Include="..\src\nb_vm.c" /> + <ClCompile Include="..\src\nb.c" /> + <ClCompile Include="..\src\nbc.c" /> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>15.0</VCProjectVersion> + <ProjectGuid>{52C647DA-51A2-49C9-8B66-ADBF48D4000F}</ProjectGuid> + <RootNamespace>noob</RootNamespace> + <WindowsTargetPlatformVersion>10.0.17763.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> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</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> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup /> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <SDLCheck>true</SDLCheck> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <SDLCheck>true</SDLCheck> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <ConformanceMode>true</ConformanceMode> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/noob/noob.vcxproj.filters b/noob/noob.vcxproj.filters new file mode 100644 index 0000000..5b4ab09 --- /dev/null +++ b/noob/noob.vcxproj.filters @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <ClInclude Include="..\src\nb_common.h" /> + <ClInclude Include="..\src\nb_debug.h" /> + <ClInclude Include="..\src\nb_util.h" /> + <ClInclude Include="..\src\noob.h" /> + <ClInclude Include="..\src\noob.hpp" /> + <ClInclude Include="..\src\nb_lexer.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_parser.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_undump.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_dump.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_libio.h"> + <Filter>lib</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_libmath.h"> + <Filter>lib</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_libos.h"> + <Filter>lib</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_token.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_opcode.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_config.h"> + <Filter>config</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_vm.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_string.h"> + <Filter>object</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_obj.h"> + <Filter>object</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_module.h"> + <Filter>lib</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_mem.h"> + <Filter>object</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_gc.h"> + <Filter>object</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_preproc.h"> + <Filter>compiler</Filter> + </ClInclude> + <ClInclude Include="..\src\nb_value.h"> + <Filter>object</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ClCompile Include="..\src\nb_debug.c" /> + <ClCompile Include="..\src\nb_util.c" /> + <ClCompile Include="..\src\nb_lexer.c"> + <Filter>compiler</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_parser.c"> + <Filter>compiler</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_undump.c"> + <Filter>compiler</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_dump.c"> + <Filter>compiler</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_libio.c"> + <Filter>lib</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_libmath.c"> + <Filter>lib</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_libos.c"> + <Filter>lib</Filter> + </ClCompile> + <ClCompile Include="..\src\nbc.c" /> + <ClCompile Include="..\src\nb.c" /> + <ClCompile Include="..\src\nb_vm.c"> + <Filter>compiler</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_obj.c"> + <Filter>object</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_string.c"> + <Filter>object</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_module.c"> + <Filter>lib</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_mem.c"> + <Filter>object</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_map.c"> + <Filter>object</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_list.c"> + <Filter>object</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_gc.c"> + <Filter>object</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_preproc.c"> + <Filter>compiler</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_hashset.c"> + <Filter>object</Filter> + </ClCompile> + <ClCompile Include="..\src\nb_value.c"> + <Filter>object</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <Filter Include="compiler"> + <UniqueIdentifier>{439752fa-f366-49b9-b33a-4c90d062d10e}</UniqueIdentifier> + </Filter> + <Filter Include="object"> + <UniqueIdentifier>{02289ad9-9700-4639-8bd9-b52c058be254}</UniqueIdentifier> + </Filter> + <Filter Include="lib"> + <UniqueIdentifier>{67fb6e00-9fd6-4bec-bd76-b57b5ff64d31}</UniqueIdentifier> + </Filter> + <Filter Include="config"> + <UniqueIdentifier>{dc95b307-8a59-47f1-88ae-cd9d18a064da}</UniqueIdentifier> + </Filter> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/noob/noob.vcxproj.user b/noob/noob.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/noob/noob.vcxproj.user @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup /> +</Project>
\ No newline at end of file diff --git a/src/nb.c b/src/nb.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb.c diff --git a/src/nb_common.h b/src/nb_common.h new file mode 100644 index 0000000..220d399 --- /dev/null +++ b/src/nb_common.h @@ -0,0 +1,18 @@ +#ifndef NB_COMMON_H +#define NB_COMMON_H + +// nbM(emory) memory +// nbX(lexer) lexer +// nbP(arser) parser +// nbV(m) vm +// nbD(ebug) debug +// nbL(load) module +// nbS(tring) string +// nb external API +// nb(map) map +// nb(list) list +// nb(hashset) hashset + +#define NB_API __declspec(dllexport) + +#endif
\ No newline at end of file diff --git a/src/nb_config.h b/src/nb_config.h new file mode 100644 index 0000000..07c74a3 --- /dev/null +++ b/src/nb_config.h @@ -0,0 +1,7 @@ +#ifndef NB_CONFIG_H +#define NB_CONFIG_H + +// ¶þ½øÖÆÎļþ¿ªÍ·±êʶ +#define NOOB_SIGNATURE "\033NB!" // <Esc>NB! + +#endif
\ No newline at end of file diff --git a/src/nb_debug.c b/src/nb_debug.c new file mode 100644 index 0000000..71fa67d --- /dev/null +++ b/src/nb_debug.c @@ -0,0 +1,10 @@ +#include "nb_debug.h" + +void nb_dump_value() { + +} + +void nb_dump_code() { + +} + diff --git a/src/nb_debug.h b/src/nb_debug.h new file mode 100644 index 0000000..6557393 --- /dev/null +++ b/src/nb_debug.h @@ -0,0 +1,8 @@ +#ifndef NB_DEBUG_H +#define NB_DEBUG_H + +void nb_dump_value(); + +void nb_dump_code(); + +#endif
\ No newline at end of file diff --git a/src/nb_dump.c b/src/nb_dump.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_dump.c diff --git a/src/nb_dump.h b/src/nb_dump.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_dump.h diff --git a/src/nb_gc.c b/src/nb_gc.c new file mode 100644 index 0000000..e26bdb9 --- /dev/null +++ b/src/nb_gc.c @@ -0,0 +1,4 @@ +#include "nb_gc.h" + + + diff --git a/src/nb_gc.h b/src/nb_gc.h new file mode 100644 index 0000000..79fed1a --- /dev/null +++ b/src/nb_gc.h @@ -0,0 +1,6 @@ +#ifndef NB_GC_H +#define NB_GC_H + + + +#endif
\ No newline at end of file diff --git a/src/nb_hashset.c b/src/nb_hashset.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_hashset.c diff --git a/src/nb_lexer.c b/src/nb_lexer.c new file mode 100644 index 0000000..6ed985d --- /dev/null +++ b/src/nb_lexer.c @@ -0,0 +1,9 @@ +#include "nb_lexer.h" + +void nbI_lexing(NbVM* vm) { + +} + +static void next() { + +} diff --git a/src/nb_lexer.h b/src/nb_lexer.h new file mode 100644 index 0000000..8360c24 --- /dev/null +++ b/src/nb_lexer.h @@ -0,0 +1,8 @@ +#ifndef NB_LEXER_H +#define NB_LEXER_H + +#include "nb_vm.h" + +void nbI_lexing(NbVM* vm); + +#endif
\ No newline at end of file diff --git a/src/nb_libio.c b/src/nb_libio.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_libio.c diff --git a/src/nb_libio.h b/src/nb_libio.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_libio.h diff --git a/src/nb_libmath.c b/src/nb_libmath.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_libmath.c diff --git a/src/nb_libmath.h b/src/nb_libmath.h new file mode 100644 index 0000000..5e723c3 --- /dev/null +++ b/src/nb_libmath.h @@ -0,0 +1,6 @@ +#ifndef NB_LIBMATH_H +#define NB_LIBMATH_H + + + +#endif
\ No newline at end of file diff --git a/src/nb_libos.c b/src/nb_libos.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_libos.c diff --git a/src/nb_libos.h b/src/nb_libos.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_libos.h diff --git a/src/nb_list.c b/src/nb_list.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_list.c diff --git a/src/nb_map.c b/src/nb_map.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_map.c diff --git a/src/nb_mem.c b/src/nb_mem.c new file mode 100644 index 0000000..a04e093 --- /dev/null +++ b/src/nb_mem.c @@ -0,0 +1,9 @@ +#include "nb_mem.h" + +void* nb_alloc(int size) { + +} + +void nb_free(void* mem) { + +} diff --git a/src/nb_mem.h b/src/nb_mem.h new file mode 100644 index 0000000..47567cb --- /dev/null +++ b/src/nb_mem.h @@ -0,0 +1,7 @@ +#ifndef NB_MEM_H +#define NB_MEM_H + +void* nb_alloc(int size); +void nb_free(void* mem); + +#endif
\ No newline at end of file diff --git a/src/nb_module.c b/src/nb_module.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_module.c diff --git a/src/nb_module.h b/src/nb_module.h new file mode 100644 index 0000000..d59fd1d --- /dev/null +++ b/src/nb_module.h @@ -0,0 +1,6 @@ +#ifndef NB_MODULE_H +#define NB_MODULE_H + +void nb_load_module(const char* module_name); + +#endif
\ No newline at end of file diff --git a/src/nb_obj.c b/src/nb_obj.c new file mode 100644 index 0000000..16b7ef3 --- /dev/null +++ b/src/nb_obj.c @@ -0,0 +1,4 @@ +#include "nb_obj.h" + + + diff --git a/src/nb_obj.h b/src/nb_obj.h new file mode 100644 index 0000000..5793045 --- /dev/null +++ b/src/nb_obj.h @@ -0,0 +1,40 @@ +#ifndef NB_OBJ_H +#define NB_OBJ_H + +#define _GCHeader GCObject* next; int tt; int marked + +typedef struct { + _GCHeader; +} GCObject; + +typedef struct { + int n; +} Instruction; + + +typedef struct { + int p; + +} Proto; // º¯ÊýÔÐÍ + + +typedef struct { + Proto* proto; + +} Closure; // ±Õ°ü + + +typedef struct { + _GCHeader; + +} Map; + +typedef struct { + _GCHeader; +} Hashset; + +typedef struct { + _GCHeader; +} List; + +#endif
\ No newline at end of file diff --git a/src/nb_opcode.h b/src/nb_opcode.h new file mode 100644 index 0000000..7bd9710 --- /dev/null +++ b/src/nb_opcode.h @@ -0,0 +1,224 @@ +#ifndef NB_OPCODE_H +#define NB_OPCODE_H + +typedef enum { + // import a external module + OP_IMPORT, // IMPORT + + // load class, enum, or mask from a module + OP_LOAD_EXTERNAL, // LOAD_EXTERNAL nameOfModule | + + OP_PUSH_CONSTANT, // PUSH_CONSTANT i | 1 + OP_PUSH_NULL, // PUSH_NULL | 1 + OP_PUSH_TRUE, // PUSH_TRUE | 1 + OP_PUSH_FALSE, // PUSH_FALSE | 1 + + // local-scoped variables + OP_LOAD_LOCAL, // LOAD_LOCAL i | 1 + OP_STORE_LOCAL, // STORE_LOCAL i | -1 + + // load or store upvalue + OP_LOAD_UPVALUE, // LOAD_UPVALUE i | 1 + OP_STORE_UPVALUE, // STORE_UPVALUE i | -1 + + // file-scoped variables + OP_LOAD_MODULE, // LOAD_MODULE i | 1 + OP_STORE_MODULE, // STORE_MODULE i | -1 + + OP_POP, // POP | 1 + OP_POPN, // POPN numOfValue | n + + OP_JUMP, // JUMP i | 0 + OP_JUMP_IF_FALSE, // JUMP_IF_FALSE | + OP_RETURN, // RETURN numOfReturn | -numOfReturn + OP_RETURN_NULL, // RETURN_NULL | + + // instansiate class + OP_INSTANTIATE, // INSTANTIATE numOfArgs | + + // call methods or functions + OP_CALL, // CALL numOfArgs | -(1+numOfArgs) + OP_OPERATOR, // OPERATOR operatorId | -(1+numOfArgs) + + // define class and method + OP_CLASS, // CLASS | 0 + OP_METHOD, // METHOD + OP_METHOD_STATIC, // METHOD_STATIC + + // load and store member of object or static member of class + OP_LOAD_FIELD, // LOAD_FIELD + OP_STORE_FIELD, // STORE_FIELD + + // call base class method, handle base. in methods + OP_CALL_BASE, // CALL_BASE numOfArgs | + + OP_TYPEOF, // + OP_INSTANCEOF, // + + // define enum or mask + OP_ENUM, // ENUM numOfElements | -(numOfElements) + OP_MASK, // MASK numOfElements | -(numOfElements) + + // create map, list or hashset + OP_MAP, + OP_LIST, + OP_HASHSET, + +} OpCode; + +// ¶ÔÓÚÔËËã·û£¬Ê¹Óà CALL Ö¸ÁÔËËã·ûµÄ²Ù×÷Êý¸öÊýÊÇÈ·¶¨µÄ +// operator numOfArgs pop +// + 2 +// ++ 1 +// += 2 +// - 2 +// -- 1 +// -= 2 +// * 2 +// *= 2 +// / 2 +// /= 2 +// ^ 2 +// ^= 2 +// % 2 +// %= 2 +// >> 2 +// >>= 2 +// << 2 +// <<= 2 +// & 2 +// | 2 +// ! 1 +// +// && 2 +// &= 2 +// || 2 +// |= 2 +// == 2 +// > 2 +// >= 2 +// < 2 +// <= 2 +// != 2 +// + + +// µ¼ÈëÄ£¿éÁ÷³Ì +// import Test; +// IMPORT +// +// import Test for CFoo; +// IMPORT "Test" +// STORE_MODULE +// POP +// +// import Test for CFoo as CClass; +// IMPORT "Test" +// LOAD_EXTERNAL "CFoo" +// STORE_MODULE 0 // "CClass" +// POPN 2 + + +// ·½·¨µ÷Óà +// var foo = new CClass(); +// var b = 20; +// foo.Func(10, b); +// LOAD_LOCAL 1 // foo +// LOAD_FIELD "Func" +// LOAD_LOCAL 1 // foo +// PUSH_CONSTANT 10 +// LOAD_LOCAL 2 // b +// CALL 3 +// +// var c = a + b; +// LOAD_LOCAL 1 // a +// LOAD_LOCAL 2 // b +// OPERATOR 1 // + + + +// º¯Êýµ÷Óà +// foo = func(10); +// LOAD_MODULE 1 // func +// PUSH_CONSTANT 1 // 10 +// CALL 1 +// STORE_LOCAL 2 // foo + +// ¶ÔÏó·½·¨ºÍº¯Êý\Àà·½·¨µÄ²»Í¬ÔÚÓÚ¶ÔÏó·½·¨»á°Ñself·ÅÔÚij¸öupvalue +// ´¦Àíself.µ÷Óà +// class CFoo { +// function foo(a) { print(self.b);} +// static function foo2(a) { print(a);} +// } +// function foo3(a) {print(a);} +// fooºÍÁíÁ½¸öµÄ²î±ðÔÚÓÚºóÁ½¸öË÷Òýµ½µÄself upvalueÊǿյ쬶øfooµÄ +// Äܹ»Ë÷Òýµ½Õâ¸öupvalue£¬ +// + +// ʵÀý»¯ +// foo = new CClass(10, 30); +// LOAD_MODULE 1 // CClass +// PUSH_CONSTANT 4 // 10 +// PUSH_CONSTANT 5 // 30 +// INSTANTIATE 2 +// STORE_LOCAL 2 // foo + + +// ´´½¨enum\mask +// enum EColor { White = 1, Blue = 2, Yellow = 3 } +// CONSTANT "EColor" +// ENUM // EColor +// CONSTANT 1 +// STORE_FIELD "White" // White = 1 +// CONSTANT 2 +// STORE_FIELD "Blue" // Blue = 1 +// CONSTANT 3 +// STORE_FIELD "Yellow" // Yellow = 1 +// POP // EColor + + +// ´´½¨map +// var foo = {"keyA" : 10, "keyB" : "hello"}; +// foo["keyC"] = 20; +// MAP +// CONSTANT 1 // 10 +// STORE_FIELD "keyA" // "keyA" : 10 +// CONSTANT "hello" +// STORE_FIELD "keyB" // "keyB" : "hello" +// LOAD_LOCAL 1 // foo +// CONSTATN 20 +// STORE_FIELD "keyC" + + +// ´´½¨list\hashset +// var foo = [1,2,3]; +// LIST +// CONSTANT 1 // 1 +// STORE_FIELD +// CONSTANT 2 +// STORE_FIELD +// CONSTANT 3 +// STORE_FIELD + + +// ¹¹½¨±Õ°ü£¬ÊµÏÖ¹Û²ìÕßģʽµÄ·½·¨ +// class CFoo { +// function OnEnable() { +// var this = self; +// // self ÕâÀï»á×÷Ϊupvalue +// onClick += function(...){this.OnClickCallback(...);}; +// } +// } + +// self.ÓÃÀ´Ë÷Òýself upvalue£¬Èç¹ûÊÇ·½·¨£¬¾Í»áË÷Òý¶ÔÏó +// base.ÓÃÀ´Ë÷Òýbase upvalue +// type.ÓÃÀ´Ë÷Òýtype upvalue +// basetype.ÓÃÀ´Ë÷Òý»ùÀàµÄupvalue + +// .ÔËËã·ûÖ»ÄÜÔËÓÃÓÚ¶ÔÏó»òÕßmap\list\hashset£¬»áÉèÖõÄupvalue: +// * self + +// À಻ÄÜÓÃ::»òÕß.Ë÷Òý¶ÔÏó·½·¨£¬Ö»ÄÜË÷Òýµ½static³ÉÔ± + +// ÔÚinitÍⲿ²»ÄÜ´´½¨ÐµĶÔÏó³ÉÔ± + +#endif
\ No newline at end of file diff --git a/src/nb_parser.c b/src/nb_parser.c new file mode 100644 index 0000000..6b2bfeb --- /dev/null +++ b/src/nb_parser.c @@ -0,0 +1,3 @@ +#include "nb_parser.h" + + diff --git a/src/nb_parser.h b/src/nb_parser.h new file mode 100644 index 0000000..d84bf8d --- /dev/null +++ b/src/nb_parser.h @@ -0,0 +1,6 @@ +#ifndef NB_PARSER_H +#define NB_PARSER_H + + + +#endif
\ No newline at end of file diff --git a/src/nb_preproc.c b/src/nb_preproc.c new file mode 100644 index 0000000..1f2e380 --- /dev/null +++ b/src/nb_preproc.c @@ -0,0 +1,9 @@ +#include "nb_preproc.h" + +void nb_set_macros(const char* macros[], int count) { + +} + +void nb_preprocess() { + +}
\ No newline at end of file diff --git a/src/nb_preproc.h b/src/nb_preproc.h new file mode 100644 index 0000000..24aa12a --- /dev/null +++ b/src/nb_preproc.h @@ -0,0 +1,16 @@ +#ifndef NB_PREPROC_H +#define NB_PREPROC_H + +#include "nb_vm.h" + +/* +* Ô¤´¦Àí +* #define +* #undef +* #if +*/ +void nb_set_macros(NbVM* vm, const char* macros[], int count); + +void nb_preprocess(NbVM* vm); + +#endif
\ No newline at end of file diff --git a/src/nb_string.c b/src/nb_string.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_string.c diff --git a/src/nb_string.h b/src/nb_string.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_string.h diff --git a/src/nb_token.h b/src/nb_token.h new file mode 100644 index 0000000..6f92dcb --- /dev/null +++ b/src/nb_token.h @@ -0,0 +1,104 @@ +#ifndef NB_TOKEN_H +#define NB_TOKEN_H + +#define TOKEN_INDEX_START 32 + +typedef enum { + TK_NULL = TOKEN_INDEX_START, // null + + TK_PLUS, // + + TK_PLUSPLUS, // ++ + TK_PLUSEQ, // += + TK_MINUS, // - + TK_MINUSMINUS, // -- + TK_MINUSEQ, // -= + TK_MULTIPLY, // * + TK_MULTIEQ, // *= + TK_SLASH, // / + TK_SLASHEQ, // /= + TK_CARET, // ^ + TK_CARETEQ, // ^= + TK_PERSENT, // % + TK_PERSENTEQ, // %= + TK_BANG, // ! + //TK_AT, // @ + //TK_QUOT, // " + TK_COMMA, // , + TK_DOT, // . + TK_DOTS, // ... + TK_COLON, // : + TK_SEMICOLON, // ; + TK_QUESTION, // ? + TK_RSHIFT, // >> + TK_RSHIFTEQ, // >>= + TK_LSHIFT, // << + TK_LSHIFTEQ, // <<= + + TK_AMP, // & + TK_AMPAMP, // && + TK_AMPEQ, // &= + TK_PIPE, // | + TK_PIPEPIPE, // || + TK_PIPEEQ, // |= + + TK_EQ, // = + TK_GT, // > + TK_GTEQ, // >= + TK_LT, // < + TK_LTEQ, // <= + TK_EQEQ, // == + TK_NOTEQ, // != + + TK_LEFT_PAREN, // ( + TK_RIGHT_PAREN, // ) + TK_LEFT_BRACKET, // [ + TK_RIGHT_BRACKET, // ] + TK_LEFT_BRACE, // { + TK_RIGHT_BRACE, // } + + TK_CLASS, // class + TK_EXTENDS, // extends + TK_NEW, // new + TK_SELF, // self + TK_TYPE, // type + TK_INTERNAL, // internal + TK_FUNCTION, // function + TK_RETURN, // return + TK_STATIC, // static + TK_VAR, // var + TK_BASE, // base + TK_IMPORT, // import + TK_AS, // as + TK_IF, // if + TK_ELSEIF, // elseif + TK_ELSE, // else + TK_FOR, // for + TK_FOREACH, // foreach + TK_IN, // in + TK_CONTINUE, // continue + TK_BREAK, // break + TK_WHILE, // while + TK_DO, // do + TK_UNTIL, // until + TK_ENUM, // enum + TK_MASK, // mask + TK_SWITCH, // switch + TK_CASE, // case + TK_DEFAULT, // default + TK_GOTO, // goto + TK_TRUE, // true + TK_FALSE, // false + + TK_TYPEOF, // typeof + TK_INSTANCEOF, // instanceof + + TK_IDENTIFIER, // <identifier> a-z A-Z 0-9 _ + TK_INT, // <int value> 0x 0c 0b + TK_DOUBLE, // <double value> + TK_STRING, // <string value> + + TK_EOF, // end of file + +} Token; + +#endif
\ No newline at end of file diff --git a/src/nb_undump.c b/src/nb_undump.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_undump.c diff --git a/src/nb_undump.h b/src/nb_undump.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_undump.h diff --git a/src/nb_util.c b/src/nb_util.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_util.c diff --git a/src/nb_util.h b/src/nb_util.h new file mode 100644 index 0000000..10ea124 --- /dev/null +++ b/src/nb_util.h @@ -0,0 +1,7 @@ +#ifndef NB_UTIL_H +#define NB_UTIL_H + +#include <assert.h> +#include <stdbool.h> + +#endif
\ No newline at end of file diff --git a/src/nb_value.c b/src/nb_value.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nb_value.c diff --git a/src/nb_value.h b/src/nb_value.h new file mode 100644 index 0000000..b8191bb --- /dev/null +++ b/src/nb_value.h @@ -0,0 +1,20 @@ +#ifndef NB_VALUE_H +#define NB_VALUE_H + +// Identifies which specific type a heap-allocated object is. +typedef enum { + OBJ_CLASS, + OBJ_CLOSURE, + OBJ_FIBER, + OBJ_FN, + OBJ_FOREIGN, + OBJ_INSTANCE, + OBJ_LIST, + OBJ_MAP, + OBJ_MODULE, + OBJ_RANGE, + OBJ_STRING, + OBJ_UPVALUE +} ObjType; + +#endif
\ No newline at end of file diff --git a/src/nb_vm.c b/src/nb_vm.c new file mode 100644 index 0000000..9bf7a2c --- /dev/null +++ b/src/nb_vm.c @@ -0,0 +1,6 @@ +#include "nb_vm.h" + +void nb_collect_garbage(NbVM* vm) { + +} + diff --git a/src/nb_vm.h b/src/nb_vm.h new file mode 100644 index 0000000..50666af --- /dev/null +++ b/src/nb_vm.h @@ -0,0 +1,14 @@ +#ifndef NB_VM_H +#define NB_VM_H + +typedef struct +{ + int pc; +} NbVM; + + +void nb_collect_garbage(NbVM* vm); + + + +#endif
\ No newline at end of file diff --git a/src/nbc.c b/src/nbc.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/nbc.c diff --git a/src/noob.h b/src/noob.h new file mode 100644 index 0000000..b8f4035 --- /dev/null +++ b/src/noob.h @@ -0,0 +1,12 @@ +#ifndef NB_H +#define NB_H + +typedef struct NbVM NbVM; + +typedef int(*NbCFunction) (NbVM* vm); + +typedef double NbDouble; +typedef int NbInt; +typedef int NbBool; + +#endif
\ No newline at end of file diff --git a/src/noob.hpp b/src/noob.hpp new file mode 100644 index 0000000..d15799f --- /dev/null +++ b/src/noob.hpp @@ -0,0 +1,6 @@ +#ifndef NB_HPP +#define NB_HPP + + + +#endif
\ No newline at end of file diff --git a/test/class.ns b/test/class.ns new file mode 100644 index 0000000..babe7ba --- /dev/null +++ b/test/class.ns @@ -0,0 +1,264 @@ +import math for Constant, math; +import io for io; // class io {...} +import gl; +import util; // util.qs or import "util.qs" +import module.common; // module/common/init.qs +import system; +import stm; + +// ²»»á±»ÊµÀý»¯µÄclassÇãÏòÓÚÓÃСд£¬ÓÃstatic class±ê¼Ç +// static class io { ... } +// ÓÃstatic ±ê¼ÇµÄclass£¬ÀïÃæµÄ·½·¨¶¼ÊǾ²Ì¬·½·¨£¬²»ÐèÒªÓÃstaticÉùÃ÷º¯Êý + +var print = io.print; + +var glv = gl.version ; + +// Ö§³Öºê +#if TEST + +#endif + +/* +* 16½øÖÆhex 0x +* 8½øÖÆoct 0c +* 2½øÖÆbin 0b +*/ +var n = 0x0f_ff_ff_ff; +n = 0c11_11_11_11; +n = 0b01_11_01_00; + +// false values: false, null, 0 + +class Test { + + function init(n) { + if( typeof(n) == "number") { + + } + self.name = ""; + self.test = n; + self.test2 = 0; + self._test = 0; + self._private = 10; + self._func = function () { + + } + } + + function foo() { + + } + + static function foo2() { + + } + + static foo3 = function() { + if(true){ + + } elif(false) { + + } else {} + } + + // release native resources here + function finalize() { + + } + + function + (right) { + return self.test + right.test + } + + function + () {} + + function - (right) { + if(right == null) { + // -test; + + } else { + // test - right + + } + } + + // ++ºÍ--Ö»ÓкóÖÃÒ»ÖÖ + function ++ (){ + self._test += 1; + } + + function -- () { + + } + + function () (param) { } + + function tostring() {} +} + +// ¶ÔÓÚÎÞ²ÎÊýº¯Êý£¬¿ÉÒÔʡȥÀ¨ºÅ¡£ÕâÊÇΪÁËʵÏÖ +// Test.instance.foo(); + +// ¼Ì³ÐÓà extends +class Test2 extends Test{ + static _instance = null; + static foo = 2; + + function init() { + base.init(); + } + + static function getInstance() { + if(_instance == null) + _instance = new Test2(); + return _instance; + } + + function finalize() { + base.finalize(); + } +} + +var Test2_ = Test2; // ÀàÒ²ÊǵÚÒ»ÀàÖµ + +var test = new Test2(); +print(typeof(test)); // Test2 +print(instanceof(test, Test1)); // true + +enum Color +{ + White = 0x1, + Red = 0x2, +}; + +//×î¶à32¸ö +mask ColorMask +{ + White, + Red, +}; + +// event +// proxy + +var Say = new event(); +Say += function(content) { + IO.Print(content); +} + +var Say = new event(); + +var a = 10; +Say(a); // fire +Say = null; + +// no global variable + +class State { + static _foo = 10; +} + +// ÈýÖÖ¼¯ºÏ +// map \ list \ hash_set + +// map\list op +// + ²¢¼¯ +// - ²î¼¯ +// * ½»¼¯ + +// map +var m = {}; +m = { + "asd" : 1, + "qwe" : null, + "embed" : { + "kll" : 2, + }, + 1 : 10, +}; + +map.add(m, "wwe", 19); +m["asd"] == m.asd; +m[1]; +var l = map.size(m); +map.join(); // m.join(); +map.intersect(); // m.intersect(); +map.differ(); // m.differ(); +map.has(m, "asd"); // true +map.contains(m, 1); // true + +foreach(var v in m) { + var key = v.key; + var value = v.value; +} + +// list +var a = []; +a = ["sdsd", 123]; +for(var i = 0; i < a.size(); ++i) { + var v = a[i]; +} +foreach(var v in a) { + var index = v.index; + var value = v.value; +} + +list.push(a, 10); // a.push(10); +list.pop(a); // a.pop(); +list.removeAt(a, 1); // a.removeAt(1); + +// hashset +var b = (); +b = (1, 2, 3, 4); +hashset.put(b, 5); + + +// raw string +//var str = r"asdasdasd"+"\"ok\""+ r"asdasd"; +var str = @" "@; +var str = @' '@; +var str = @| |@; + +// main entry + +function main() { + +} + +main(); + + +// bool +// int +// double + +// ĬÈÏÈ«¾ÖµÄÀàÐÍ +// class +// enum +// mask + +// ÓÃinternal½«class\enum\maskÄÚ²¿»¯£¬Ö»Óб¾ÎļþÄÚ¿É·ÃÎÊ + +internal class CFoo { + +} + +internal enum Type { + +} + +internal mask TypeMask { + +} + + +// upvalue +function foo() { + var a = 10; // upvalue + return function() { + return a++; + } +} +var f = foo(); +f(); diff --git a/test/math/constant.qwe b/test/math/constant.qwe new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/math/constant.qwe diff --git a/test/math/init.qwe b/test/math/init.qwe new file mode 100644 index 0000000..d9b1ae9 --- /dev/null +++ b/test/math/init.qwe @@ -0,0 +1,2 @@ +import "constant"; + diff --git a/test/module/common/basic.qwe b/test/module/common/basic.qwe new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/module/common/basic.qwe diff --git a/test/module/common/init.qwe b/test/module/common/init.qwe new file mode 100644 index 0000000..b6e40cc --- /dev/null +++ b/test/module/common/init.qwe @@ -0,0 +1,3 @@ + +import "basic.qwe"; + diff --git a/test/qson/test.qson b/test/qson/test.qson new file mode 100644 index 0000000..35c70e5 --- /dev/null +++ b/test/qson/test.qson @@ -0,0 +1,6 @@ +{ + "test2" : [1,2,3], + "test3" : 10, + 1 : 2, + "address" : {}, +}
\ No newline at end of file |