Created Visual Studio 2011 project.
Modified to compile under Visual Studio 2011. git-svn-id: http://picoc.googlecode.com/svn/trunk@572 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
bd7634d75b
commit
cb4c34b506
|
@ -114,8 +114,12 @@ void StdioFprintfWord(StdOutStream *Stream, const char *Format, unsigned int Val
|
|||
|
||||
else if (Stream->StrOutLen >= 0)
|
||||
{
|
||||
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
|
||||
Stream->StrOutPtr += CCount;
|
||||
#ifndef WIN32
|
||||
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
|
||||
#else
|
||||
int CCount = _snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
|
||||
#endif
|
||||
Stream->StrOutPtr += CCount;
|
||||
Stream->StrOutLen -= CCount;
|
||||
Stream->CharCount += CCount;
|
||||
}
|
||||
|
@ -135,8 +139,12 @@ void StdioFprintfFP(StdOutStream *Stream, const char *Format, double Value)
|
|||
|
||||
else if (Stream->StrOutLen >= 0)
|
||||
{
|
||||
#ifndef WIN32
|
||||
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
|
||||
Stream->StrOutPtr += CCount;
|
||||
#else
|
||||
int CCount = _snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
|
||||
#endif
|
||||
Stream->StrOutPtr += CCount;
|
||||
Stream->StrOutLen -= CCount;
|
||||
Stream->CharCount += CCount;
|
||||
}
|
||||
|
@ -156,7 +164,11 @@ void StdioFprintfPointer(StdOutStream *Stream, const char *Format, void *Value)
|
|||
|
||||
else if (Stream->StrOutLen >= 0)
|
||||
{
|
||||
#ifndef WIN32
|
||||
int CCount = snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
|
||||
#else
|
||||
int CCount = _snprintf(Stream->StrOutPtr, Stream->StrOutLen, Format, Value);
|
||||
#endif
|
||||
Stream->StrOutPtr += CCount;
|
||||
Stream->StrOutLen -= CCount;
|
||||
Stream->CharCount += CCount;
|
||||
|
@ -414,7 +426,11 @@ void StdioFerror(struct ParseState *Parser, struct Value *ReturnValue, struct Va
|
|||
|
||||
void StdioFileno(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
#ifndef WIN32
|
||||
ReturnValue->Val->Integer = fileno(Param[0]->Val->Pointer);
|
||||
#else
|
||||
ReturnValue->Val->Integer = _fileno(Param[0]->Val->Pointer);
|
||||
#endif
|
||||
}
|
||||
|
||||
void StdioFflush(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
|
|
|
@ -35,6 +35,7 @@ void StringStrncat(struct ParseState *Parser, struct Value *ReturnValue, struct
|
|||
ReturnValue->Val->Pointer = strncat(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
void StringIndex(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Pointer = index(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
|
@ -44,6 +45,7 @@ void StringRindex(struct ParseState *Parser, struct Value *ReturnValue, struct V
|
|||
{
|
||||
ReturnValue->Val->Pointer = rindex(Param[0]->Val->Pointer, Param[1]->Val->Integer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void StringStrlen(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
|
@ -125,6 +127,7 @@ void StringStrxfrm(struct ParseState *Parser, struct Value *ReturnValue, struct
|
|||
ReturnValue->Val->Integer = strxfrm(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Integer);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
void StringStrdup(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Pointer = strdup(Param[0]->Val->Pointer);
|
||||
|
@ -134,12 +137,15 @@ void StringStrtok_r(struct ParseState *Parser, struct Value *ReturnValue, struct
|
|||
{
|
||||
ReturnValue->Val->Pointer = strtok_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* all string.h functions */
|
||||
struct LibraryFunction StringFunctions[] =
|
||||
{
|
||||
{ StringIndex, "char *index(char *,int);" },
|
||||
#ifndef WIN32
|
||||
{ StringIndex, "char *index(char *,int);" },
|
||||
{ StringRindex, "char *rindex(char *,int);" },
|
||||
#endif
|
||||
{ StringMemcpy, "void *memcpy(void *,void *,int);" },
|
||||
{ StringMemmove, "void *memmove(void *,void *,int);" },
|
||||
{ StringMemchr, "void *memchr(char *,int,int);" },
|
||||
|
@ -162,8 +168,10 @@ struct LibraryFunction StringFunctions[] =
|
|||
{ StringStrstr, "char *strstr(char *,char *);" },
|
||||
{ StringStrtok, "char *strtok(char *,char *);" },
|
||||
{ StringStrxfrm, "int strxfrm(char *,char *,int);" },
|
||||
{ StringStrdup, "char *strdup(char *);" },
|
||||
#ifndef WIN32
|
||||
{ StringStrdup, "char *strdup(char *);" },
|
||||
{ StringStrtok_r, "char *strtok_r(char *,char *,char **);" },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -41,11 +41,6 @@ void StdGmtime(struct ParseState *Parser, struct Value *ReturnValue, struct Valu
|
|||
ReturnValue->Val->Pointer = gmtime(Param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Pointer = gmtime_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdLocaltime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Pointer = localtime(Param[0]->Val->Pointer);
|
||||
|
@ -53,12 +48,12 @@ void StdLocaltime(struct ParseState *Parser, struct Value *ReturnValue, struct V
|
|||
|
||||
void StdMktime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = mktime(Param[0]->Val->Pointer);
|
||||
ReturnValue->Val->Integer = (int)mktime(Param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdTime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = time(Param[0]->Val->Pointer);
|
||||
ReturnValue->Val->Integer = (int)time(Param[0]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdStrftime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
|
@ -66,6 +61,7 @@ void StdStrftime(struct ParseState *Parser, struct Value *ReturnValue, struct Va
|
|||
ReturnValue->Val->Integer = strftime(Param[0]->Val->Pointer, Param[1]->Val->Integer, Param[2]->Val->Pointer, Param[3]->Val->Pointer);
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
void StdStrptime(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
extern char *strptime(const char *s, const char *format, struct tm *tm);
|
||||
|
@ -73,10 +69,16 @@ void StdStrptime(struct ParseState *Parser, struct Value *ReturnValue, struct Va
|
|||
ReturnValue->Val->Pointer = strptime(Param[0]->Val->Pointer, Param[1]->Val->Pointer, Param[2]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdGmtime_r(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Pointer = gmtime_r(Param[0]->Val->Pointer, Param[1]->Val->Pointer);
|
||||
}
|
||||
|
||||
void StdTimegm(struct ParseState *Parser, struct Value *ReturnValue, struct Value **Param, int NumArgs)
|
||||
{
|
||||
ReturnValue->Val->Integer = timegm(Param[0]->Val->Pointer);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* handy structure definitions */
|
||||
const char StdTimeDefs[] = "\
|
||||
|
@ -94,13 +96,15 @@ struct LibraryFunction StdTimeFunctions[] =
|
|||
{ StdDifftime, "double difftime(int, int);" },
|
||||
#endif
|
||||
{ StdGmtime, "struct tm *gmtime(int *);" },
|
||||
{ StdGmtime_r, "struct tm *gmtime_r(int *, struct tm *);" },
|
||||
{ StdLocaltime, "struct tm *localtime(int *);" },
|
||||
{ StdMktime, "int mktime(struct tm *ptm);" },
|
||||
{ StdTime, "int time(int *);" },
|
||||
{ StdStrftime, "int strftime(char *, int, char *, struct tm *);" },
|
||||
#ifndef WIN32
|
||||
{ StdStrptime, "char *strptime(char *, char *, struct tm *);" },
|
||||
{ StdGmtime_r, "struct tm *gmtime_r(int *, struct tm *);" },
|
||||
{ StdTimegm, "int timegm(struct tm *);" },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -370,11 +370,11 @@ void ExpressionAssign(struct ParseState *Parser, struct Value *DestValue, struct
|
|||
switch (DestValue->Typ->Base)
|
||||
{
|
||||
case TypeInt: DestValue->Val->Integer = ExpressionCoerceInteger(SourceValue); break;
|
||||
case TypeShort: DestValue->Val->ShortInteger = ExpressionCoerceInteger(SourceValue); break;
|
||||
case TypeChar: DestValue->Val->Character = ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
case TypeShort: DestValue->Val->ShortInteger = (short)ExpressionCoerceInteger(SourceValue); break;
|
||||
case TypeChar: DestValue->Val->Character = (unsigned char)ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
case TypeLong: DestValue->Val->LongInteger = ExpressionCoerceInteger(SourceValue); break;
|
||||
case TypeUnsignedInt: DestValue->Val->UnsignedInteger = ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
case TypeUnsignedShort: DestValue->Val->UnsignedShortInteger = ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
case TypeUnsignedShort: DestValue->Val->UnsignedShortInteger = (unsigned short)ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
case TypeUnsignedLong: DestValue->Val->UnsignedLongInteger = ExpressionCoerceUnsignedInteger(SourceValue); break;
|
||||
|
||||
#ifndef NO_FP
|
||||
|
@ -1171,7 +1171,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
|||
|
||||
ExpressionStackPushValueNode(Parser, &StackTop, MacroResult);
|
||||
}
|
||||
else if (VariableValue->Typ == TypeVoid)
|
||||
else if (VariableValue->Typ == &VoidType)
|
||||
ProgramFail(Parser, "a void value isn't much use here");
|
||||
else
|
||||
ExpressionStackPushLValue(Parser, &StackTop, VariableValue, 0); /* it's a value variable */
|
||||
|
|
|
@ -25,15 +25,17 @@ void IncludeInit()
|
|||
#ifndef BUILTIN_MINI_STDLIB
|
||||
IncludeRegister("ctype.h", NULL, &StdCtypeFunctions[0], NULL);
|
||||
IncludeRegister("errno.h", &StdErrnoSetupFunc, NULL, NULL);
|
||||
#ifndef NO_FP
|
||||
# ifndef NO_FP
|
||||
IncludeRegister("math.h", &MathSetupFunc, &MathFunctions[0], NULL);
|
||||
#endif
|
||||
# endif
|
||||
IncludeRegister("stdbool.h", &StdboolSetupFunc, NULL, StdboolDefs);
|
||||
IncludeRegister("stdio.h", &StdioSetupFunc, &StdioFunctions[0], StdioDefs);
|
||||
IncludeRegister("stdlib.h", &StdlibSetupFunc, &StdlibFunctions[0], NULL);
|
||||
IncludeRegister("string.h", &StringSetupFunc, &StringFunctions[0], NULL);
|
||||
IncludeRegister("time.h", &StdTimeSetupFunc, &StdTimeFunctions[0], StdTimeDefs);
|
||||
IncludeRegister("unistd.h", &UnistdSetupFunc, &UnistdFunctions[0], UnistdDefs);
|
||||
# ifndef WIN32
|
||||
IncludeRegister("unistd.h", &UnistdSetupFunc, &UnistdFunctions[0], UnistdDefs);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
2
lex.c
2
lex.c
|
@ -28,7 +28,7 @@
|
|||
#define MAX_CHAR_VALUE 255 /* maximum value which can be represented by a "char" data type */
|
||||
|
||||
static union AnyValue LexAnyValue;
|
||||
static struct Value LexValue = { TypeVoid, &LexAnyValue, NULL, FALSE, FALSE, FALSE };
|
||||
static struct Value LexValue = { &VoidType, &LexAnyValue, NULL, FALSE, FALSE, FALSE };
|
||||
|
||||
struct ReservedWord
|
||||
{
|
||||
|
|
20
msvc/picoc/picoc.sln
Normal file
20
msvc/picoc/picoc.sln
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 11
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "picoc", "picoc.vcxproj", "{C0156FB3-55AB-4F82-8A97-A776DFC57951}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C0156FB3-55AB-4F82-8A97-A776DFC57951}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
111
msvc/picoc/picoc.vcxproj
Normal file
111
msvc/picoc/picoc.vcxproj
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.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>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCTargetsPath Condition="'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and '$(VisualStudioVersion)' == ''">$(VCTargetsPath11)</VCTargetsPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C0156FB3-55AB-4F82-8A97-A776DFC57951}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>picoc</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</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>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\clibrary.c" />
|
||||
<ClCompile Include="..\..\cstdlib\ctype.c" />
|
||||
<ClCompile Include="..\..\cstdlib\errno.c" />
|
||||
<ClCompile Include="..\..\cstdlib\math.c" />
|
||||
<ClCompile Include="..\..\cstdlib\stdbool.c" />
|
||||
<ClCompile Include="..\..\cstdlib\stdio.c" />
|
||||
<ClCompile Include="..\..\cstdlib\stdlib.c" />
|
||||
<ClCompile Include="..\..\cstdlib\string.c" />
|
||||
<ClCompile Include="..\..\cstdlib\time.c" />
|
||||
<ClCompile Include="..\..\debug.c" />
|
||||
<ClCompile Include="..\..\expression.c" />
|
||||
<ClCompile Include="..\..\heap.c" />
|
||||
<ClCompile Include="..\..\include.c" />
|
||||
<ClCompile Include="..\..\lex.c" />
|
||||
<ClCompile Include="..\..\parse.c" />
|
||||
<ClCompile Include="..\..\picoc.c" />
|
||||
<ClCompile Include="..\..\platform.c" />
|
||||
<ClCompile Include="..\..\platform\library_msvc.c" />
|
||||
<ClCompile Include="..\..\platform\platform_msvc.c" />
|
||||
<ClCompile Include="..\..\table.c" />
|
||||
<ClCompile Include="..\..\type.c" />
|
||||
<ClCompile Include="..\..\variable.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\interpreter.h" />
|
||||
<ClInclude Include="..\..\picoc.h" />
|
||||
<ClInclude Include="..\..\platform.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
99
msvc/picoc/picoc.vcxproj.filters
Normal file
99
msvc/picoc/picoc.vcxproj.filters
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files\cstdlib">
|
||||
<UniqueIdentifier>{9cc822ce-c7ed-4deb-93d2-ab0077cfe681}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\clibrary.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\debug.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\expression.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\heap.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\include.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\lex.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\parse.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\picoc.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\platform.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\table.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\type.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\variable.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\ctype.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\errno.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\math.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\stdbool.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\stdio.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\stdlib.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\string.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\cstdlib\time.c">
|
||||
<Filter>Source Files\cstdlib</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\platform\library_msvc.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\platform\platform_msvc.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\interpreter.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\picoc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\platform.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
2
picoc.c
2
picoc.c
|
@ -6,7 +6,7 @@
|
|||
|
||||
/* platform-dependent code for running programs is in this file */
|
||||
|
||||
#ifdef UNIX_HOST
|
||||
#if defined(UNIX_HOST) || defined(WIN32)
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
2
picoc.h
2
picoc.h
|
@ -17,7 +17,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef UNIX_HOST
|
||||
#if defined(UNIX_HOST) || defined(WIN32)
|
||||
#include <setjmp.h>
|
||||
|
||||
/* mark where to end the program for platforms which require this */
|
||||
|
|
|
@ -46,7 +46,7 @@ void PicocCleanup()
|
|||
}
|
||||
|
||||
/* platform-dependent code for running programs */
|
||||
#ifdef UNIX_HOST
|
||||
#if defined(UNIX_HOST) || defined(WIN32)
|
||||
|
||||
#define CALL_MAIN_NO_ARGS_RETURN_VOID "main();"
|
||||
#define CALL_MAIN_WITH_ARGS_RETURN_VOID "main(__argc,__argv);"
|
||||
|
@ -124,7 +124,7 @@ void PrintSourceTextErrorLine(const char *FileName, const char *SourceText, int
|
|||
else
|
||||
{
|
||||
/* assume we're in interactive mode - try to make the arrow match up with the input text */
|
||||
for (CCount = 0; CCount < CharacterPos + strlen(INTERACTIVE_PROMPT_STATEMENT); CCount++)
|
||||
for (CCount = 0; CCount < CharacterPos + (int)strlen(INTERACTIVE_PROMPT_STATEMENT); CCount++)
|
||||
PrintCh(' ', CStdOut);
|
||||
}
|
||||
PlatformPrintf("^\n%s:%d: ", FileName, Line, CharacterPos);
|
||||
|
|
103
platform.h
103
platform.h
|
@ -9,6 +9,7 @@
|
|||
* #define SURVEYOR_HOST
|
||||
* #define SRV1_UNIX_HOST
|
||||
* #define UMON_HOST
|
||||
* #define WIN32 (predefined on MSVC)
|
||||
*/
|
||||
|
||||
#define LARGE_INT_POWER_OF_TEN 1000000000 /* the largest power of ten which fits in an int on this architecture */
|
||||
|
@ -57,63 +58,83 @@
|
|||
extern jmp_buf ExitBuf;
|
||||
|
||||
#else
|
||||
# ifdef FLYINGFOX_HOST
|
||||
# define HEAP_SIZE (16*1024) /* space for the heap and the stack */
|
||||
# define NO_HASH_INCLUDE
|
||||
# ifdef WIN32
|
||||
# define USE_MALLOC_STACK /* stack is allocated using malloc() */
|
||||
# define USE_MALLOC_HEAP /* heap is allocated using malloc() */
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <ctype.h>
|
||||
# include <string.h>
|
||||
# include <assert.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# include <stdarg.h>
|
||||
# include <setjmp.h>
|
||||
# include <math.h>
|
||||
# define assert(x)
|
||||
# define BUILTIN_MINI_STDLIB
|
||||
# define PICOC_MATH_LIBRARY
|
||||
# undef BIG_ENDIAN
|
||||
|
||||
extern jmp_buf ExitBuf;
|
||||
|
||||
# else
|
||||
# ifdef SURVEYOR_HOST
|
||||
# define HEAP_SIZE C_HEAPSIZE
|
||||
# define NO_FP
|
||||
# define NO_CTYPE
|
||||
# ifdef FLYINGFOX_HOST
|
||||
# define HEAP_SIZE (16*1024) /* space for the heap and the stack */
|
||||
# define NO_HASH_INCLUDE
|
||||
# define NO_MODULUS
|
||||
# include <cdefBF537.h>
|
||||
# include "../string.h"
|
||||
# include "../print.h"
|
||||
# include "../srv.h"
|
||||
# include "../setjmp.h"
|
||||
# include "../stdarg.h"
|
||||
# include "../colors.h"
|
||||
# include "../neural.h"
|
||||
# include "../gps.h"
|
||||
# include "../i2c.h"
|
||||
# include "../jpeg.h"
|
||||
# include "../malloc.h"
|
||||
# include "../xmodem.h"
|
||||
# include <stdlib.h>
|
||||
# include <ctype.h>
|
||||
# include <string.h>
|
||||
# include <sys/types.h>
|
||||
# include <stdarg.h>
|
||||
# include <setjmp.h>
|
||||
# include <math.h>
|
||||
# define assert(x)
|
||||
# undef BIG_ENDIAN
|
||||
# define NO_CALLOC
|
||||
# define NO_REALLOC
|
||||
# define BROKEN_FLOAT_CASTS
|
||||
# define BUILTIN_MINI_STDLIB
|
||||
# undef BIG_ENDIAN
|
||||
|
||||
# else
|
||||
# ifdef UMON_HOST
|
||||
# define HEAP_SIZE (128*1024) /* space for the heap and the stack */
|
||||
# ifdef SURVEYOR_HOST
|
||||
# define HEAP_SIZE C_HEAPSIZE
|
||||
# define NO_FP
|
||||
# define BUILTIN_MINI_STDLIB
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <ctype.h>
|
||||
# include <sys/types.h>
|
||||
# include <stdarg.h>
|
||||
# include <math.h>
|
||||
# include "monlib.h"
|
||||
# define NO_CTYPE
|
||||
# define NO_HASH_INCLUDE
|
||||
# define NO_MODULUS
|
||||
# include <cdefBF537.h>
|
||||
# include "../string.h"
|
||||
# include "../print.h"
|
||||
# include "../srv.h"
|
||||
# include "../setjmp.h"
|
||||
# include "../stdarg.h"
|
||||
# include "../colors.h"
|
||||
# include "../neural.h"
|
||||
# include "../gps.h"
|
||||
# include "../i2c.h"
|
||||
# include "../jpeg.h"
|
||||
# include "../malloc.h"
|
||||
# include "../xmodem.h"
|
||||
# define assert(x)
|
||||
# define malloc mon_malloc
|
||||
# define calloc(a,b) mon_malloc(a*b)
|
||||
# define realloc mon_realloc
|
||||
# define free mon_free
|
||||
# undef BIG_ENDIAN
|
||||
# define NO_CALLOC
|
||||
# define NO_REALLOC
|
||||
# define BROKEN_FLOAT_CASTS
|
||||
# define BUILTIN_MINI_STDLIB
|
||||
# else
|
||||
# ifdef UMON_HOST
|
||||
# define HEAP_SIZE (128*1024) /* space for the heap and the stack */
|
||||
# define NO_FP
|
||||
# define BUILTIN_MINI_STDLIB
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <ctype.h>
|
||||
# include <sys/types.h>
|
||||
# include <stdarg.h>
|
||||
# include <math.h>
|
||||
# include "monlib.h"
|
||||
# define assert(x)
|
||||
# define malloc mon_malloc
|
||||
# define calloc(a,b) mon_malloc(a*b)
|
||||
# define realloc mon_realloc
|
||||
# define free mon_free
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
|
5
platform/library_msvc.c
Normal file
5
platform/library_msvc.c
Normal file
|
@ -0,0 +1,5 @@
|
|||
#include "../interpreter.h"
|
||||
|
||||
void PlatformLibraryInit()
|
||||
{
|
||||
}
|
80
platform/platform_msvc.c
Normal file
80
platform/platform_msvc.c
Normal file
|
@ -0,0 +1,80 @@
|
|||
#include "../picoc.h"
|
||||
#include "../interpreter.h"
|
||||
|
||||
/* mark where to end the program for platforms which require this */
|
||||
jmp_buf PicocExitBuf;
|
||||
|
||||
void PlatformInit()
|
||||
{
|
||||
}
|
||||
|
||||
void PlatformCleanup()
|
||||
{
|
||||
}
|
||||
|
||||
/* get a line of interactive input */
|
||||
char *PlatformGetLine(char *Buf, int MaxLen, const char *Prompt)
|
||||
{
|
||||
if (Prompt != NULL)
|
||||
printf("%s", Prompt);
|
||||
|
||||
fflush(stdout);
|
||||
return fgets(Buf, MaxLen, stdin);
|
||||
}
|
||||
|
||||
/* get a character of interactive input */
|
||||
int PlatformGetCharacter()
|
||||
{
|
||||
fflush(stdout);
|
||||
return getchar();
|
||||
}
|
||||
|
||||
/* write a character to the console */
|
||||
void PlatformPutc(unsigned char OutCh, union OutputStreamInfo *Stream)
|
||||
{
|
||||
putchar(OutCh);
|
||||
}
|
||||
|
||||
/* read a file into memory */
|
||||
char *PlatformReadFile(const char *FileName)
|
||||
{
|
||||
struct stat FileInfo;
|
||||
char *ReadText;
|
||||
FILE *InFile;
|
||||
int BytesRead;
|
||||
|
||||
if (stat(FileName, &FileInfo))
|
||||
ProgramFail(NULL, "can't read file %s\n", FileName);
|
||||
|
||||
ReadText = malloc(FileInfo.st_size + 1);
|
||||
if (ReadText == NULL)
|
||||
ProgramFail(NULL, "out of memory\n");
|
||||
|
||||
InFile = fopen(FileName, "r");
|
||||
if (InFile == NULL)
|
||||
ProgramFail(NULL, "can't read file %s\n", FileName);
|
||||
|
||||
BytesRead = fread(ReadText, 1, FileInfo.st_size, InFile);
|
||||
if (BytesRead == 0)
|
||||
ProgramFail(NULL, "can't read file %s\n", FileName);
|
||||
|
||||
ReadText[BytesRead] = '\0';
|
||||
fclose(InFile);
|
||||
|
||||
return ReadText;
|
||||
}
|
||||
|
||||
/* read and scan a file for definitions */
|
||||
void PicocPlatformScanFile(const char *FileName)
|
||||
{
|
||||
char *SourceStr = PlatformReadFile(FileName);
|
||||
|
||||
PicocParse(FileName, SourceStr, strlen(SourceStr), TRUE, FALSE, TRUE, TRUE);
|
||||
}
|
||||
|
||||
/* exit the program */
|
||||
void PlatformExit(int RetVal)
|
||||
{
|
||||
PicocExitValue = RetVal;
|
||||
longjmp(PicocExitBuf, 1);
|
||||
}
|
Loading…
Reference in a new issue