Permalink
Browse files

Update sample projects according to the newest LLVM# API + .Net Core …

…2.0 (#58)

* update to .netcore 2.0

* fix bug of api changes

* migrate to the newest API

* add travis config

* Update .travis.yml

* revert changes

* add `this`

* remove package.json

* finally
  • Loading branch information...
ice1000 authored and mjsabby committed Oct 12, 2017
1 parent c7fc838 commit c4fcf6c877885b50ddd75cf28cab908dc6ea458c
View
@@ -0,0 +1,12 @@
language: csharp
mono: none
dotnet: 2.0.0
dist: trusty
solution: LLVMSharp.sln
cache:
apt: true
script:
- dotnet restore
- dotnet build
@@ -1,67 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CD23CB2E-951B-4FAD-A4CD-4048731DBA31}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Kaleidoscope</RootNamespace>
<AssemblyName>Kaleidoscope</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<NuGetPackageImportStamp>0e4b5d39</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="AST\BinaryExprAST.cs" />
<Compile Include="AST\CallExprAST.cs" />
<Compile Include="AST\ExprAST.cs" />
<Compile Include="AST\ExprVisitor.cs" />
<Compile Include="AST\ExprType.cs" />
<Compile Include="AST\FunctionAST.cs" />
<Compile Include="IParser.cs" />
<Compile Include="ILexer.cs" />
<Compile Include="AST\NumberExprAST.cs" />
<Compile Include="IParserListener.cs" />
<Compile Include="Parser.cs" />
<Compile Include="AST\PrototypeAST.cs" />
<Compile Include="Lexer.cs" />
<Compile Include="BaseParserListener.cs" />
<Compile Include="Token.cs" />
<Compile Include="AST\VariableExprAST.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CD23CB2E-951B-4FAD-A4CD-4048731DBA31}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Kaleidoscope</RootNamespace>
<AssemblyName>Kaleidoscope</AssemblyName>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NuGetPackageImportStamp>0e4b5d39</NuGetPackageImportStamp>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
</Project>
@@ -1,10 +1,10 @@
namespace KaleidoscopeLLVM
{
using System;
using System.Collections.Generic;
using Kaleidoscope.AST;
using LLVMSharp;
using System;
using System.Collections.Generic;
using Kaleidoscope.AST;
using LLVMSharp;
namespace KaleidoscopeLLVM
{
internal sealed class CodeGenVisitor : ExprVisitor
{
private static readonly LLVMBool LLVMBoolFalse = new LLVMBool(0);
@@ -25,7 +25,7 @@ public CodeGenVisitor(LLVMModuleRef module, LLVMBuilderRef builder)
this.builder = builder;
}
public Stack<LLVMValueRef> ResultStack { get { return this.valueStack; } }
public Stack<LLVMValueRef> ResultStack { get { return valueStack; } }
public void ClearResultStack()
{
@@ -109,7 +109,7 @@ protected override ExprAST VisitCallExprAST(CallExprAST node)
argsV[i] = this.valueStack.Pop();
}
this.valueStack.Push(LLVM.BuildCall(this.builder, calleeF, out argsV[0], argumentCount, "calltmp"));
valueStack.Push(LLVM.BuildCall(this.builder, calleeF, argsV, "calltmp"));
return node;
}
@@ -145,7 +145,7 @@ protected override ExprAST VisitPrototypeAST(PrototypeAST node)
arguments[i] = LLVM.DoubleType();
}
function = LLVM.AddFunction(this.module, node.Name, LLVM.FunctionType(LLVM.DoubleType(), out arguments[0], argumentCount, LLVMBoolFalse));
function = LLVM.AddFunction(this.module, node.Name, LLVM.FunctionType(LLVM.DoubleType(), arguments, LLVMBoolFalse));
LLVM.SetLinkage(function, LLVMLinkage.LLVMExternalLinkage);
}
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -9,76 +8,24 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>KaleidoscopeLLVM</RootNamespace>
<AssemblyName>KaleidoscopeLLVM</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFramework>netcoreapp2.0</TargetFramework>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>b8df454a</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="LLVMSharp">
<HintPath>..\ConsoleApplication4\packages\LLVMSharp.3.5.5\lib\net40\LLVMSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="CodeGenVisitor.cs" />
<Compile Include="CodeGenParserListener.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConsoleApplication4\Kaleidoscope.csproj">
<Project>{cd23cb2e-951b-4fad-a4cd-4048731dba31}</Project>
<Name>Kaleidoscope</Name>
</ProjectReference>
<ProjectReference Include="..\Kaleidoscope\Kaleidoscope.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="x64\llvm.dll" />
<Content Include="x86\llvm.dll" />
<PackageReference Include="LLVMSharp" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<Folder Include="Properties" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\ConsoleApplication4\packages\LLVMSharp.3.5.5\build\LLVMSharp.targets" Condition="Exists('..\ConsoleApplication4\packages\LLVMSharp.3.5.5\build\LLVMSharp.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\ConsoleApplication4\packages\LLVMSharp.3.5.5\build\LLVMSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\ConsoleApplication4\packages\LLVMSharp.3.5.5\build\LLVMSharp.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -16,11 +16,14 @@ private static void Main(string[] args)
// Install standard binary operators.
// 1 is lowest precedence.
var binopPrecedence = new Dictionary<char, int>();
binopPrecedence['<'] = 10;
binopPrecedence['+'] = 20;
binopPrecedence['-'] = 20;
binopPrecedence['*'] = 40; // highest.
var binopPrecedence = new Dictionary<char, int>
{
['<'] = 10,
['+'] = 20,
['-'] = 20,
['*'] = 40
};
// highest.
var scanner = new Lexer(Console.In, binopPrecedence);
var parser = new Parser(scanner, codeGenlistener);

This file was deleted.

Oops, something went wrong.
@@ -1,67 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CD23CB2E-951B-4FAD-A4CD-4048731DBA31}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Kaleidoscope</RootNamespace>
<AssemblyName>Kaleidoscope</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<NuGetPackageImportStamp>0e4b5d39</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="AST\BinaryExprAST.cs" />
<Compile Include="AST\CallExprAST.cs" />
<Compile Include="AST\ExprAST.cs" />
<Compile Include="AST\ExprVisitor.cs" />
<Compile Include="AST\ExprType.cs" />
<Compile Include="AST\FunctionAST.cs" />
<Compile Include="IParser.cs" />
<Compile Include="ILexer.cs" />
<Compile Include="AST\NumberExprAST.cs" />
<Compile Include="IParserListener.cs" />
<Compile Include="Parser.cs" />
<Compile Include="AST\PrototypeAST.cs" />
<Compile Include="Lexer.cs" />
<Compile Include="BaseParserListener.cs" />
<Compile Include="Token.cs" />
<Compile Include="AST\VariableExprAST.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CD23CB2E-951B-4FAD-A4CD-4048731DBA31}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Kaleidoscope</RootNamespace>
<AssemblyName>Kaleidoscope</AssemblyName>
<TargetFramework>netcoreapp2.0</TargetFramework>
<NuGetPackageImportStamp>0e4b5d39</NuGetPackageImportStamp>
</PropertyGroup>
</Project>
Oops, something went wrong.

0 comments on commit c4fcf6c

Please sign in to comment.