From 609aebe90bb795a05f5f378ee71efaa1732d9a53 Mon Sep 17 00:00:00 2001 From: kudzu_cp <6d05c8c8ef5431987001abfdb2eadc9593ac9498> Date: Sat, 12 Jul 2014 18:47:29 +0000 Subject: [PATCH] --- Setup2/Cosmos.iss | 2 +- source/XSharp Projects.txt | 2 + .../Cosmos.Compiler.DebugStub/AsmBreak.asm | 1 + .../Cosmos.Compiler.DebugStub/AsmBreak.xs | 1 + .../Compiler/Cosmos.XSharp/AsmGenerator.cs | 61 +++++++++---------- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/Setup2/Cosmos.iss b/Setup2/Cosmos.iss index 50defb702..0933e7209 100644 --- a/Setup2/Cosmos.iss +++ b/Setup2/Cosmos.iss @@ -325,7 +325,7 @@ Root: HKLM; SubKey: Software\Microsoft\VisualStudio\12.0\Generators\{{FAE04EC1-3 ; X# file generator type Root: HKLM; SubKey: Software\Microsoft\VisualStudio\12.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: none; Flags: uninsdeletekey Root: HKLM; SubKey: Software\Microsoft\VisualStudio\12.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: Assembly; ValueData: Cosmos.VS.XSharp -Root: HKLM; SubKey: Software\Microsoft\VisualStudio\12.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: Class; ValueData: Cosmos.VS.XSharp.FileGenerator +Root: HKLM; SubKey: Software\Microsoft\VisualStudio\12.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: Class; ValueData: Cosmos.VS.XSharp.XsToAsmFileGenerator Root: HKLM; SubKey: Software\Microsoft\VisualStudio\12.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: InprocServer32; ValueData: {sys}\mscoree.dll Root: HKLM; SubKey: Software\Microsoft\VisualStudio\12.0\CLSID\{{D6F57DE8-E50E-4C91-99E1-FA2E262BC4EA}; ValueType: string; ValueName: CodeBase; ValueData: {app}\build\vsip\Cosmos.VS.XSharp.dll diff --git a/source/XSharp Projects.txt b/source/XSharp Projects.txt index df5484d47..de223aa32 100644 --- a/source/XSharp Projects.txt +++ b/source/XSharp Projects.txt @@ -9,6 +9,8 @@ Compiler for XSharp ----------------------------------------------------------------------------- Cosmos.VS.XSharp Library - VS Language Service +Rebuild - Rerun install.bat + VS extension for support for X#. ----------------------------------------------------------------------------- diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.asm b/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.asm index ea21abc1f..ddaff6e15 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.asm +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.asm @@ -57,6 +57,7 @@ Pop EAX Pop EBP DebugStub_SetINT1_TrapFLAG_Exit: Ret + DebugStub_ResetINT1_TrapFLAG: Push EBP Push EAX diff --git a/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.xs b/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.xs index 889de485a..6cf75a38c 100644 --- a/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.xs +++ b/source2/Compiler/Cosmos.Compiler.DebugStub/AsmBreak.xs @@ -71,6 +71,7 @@ function SetINT1_TrapFLAG { -EAX -EBP } + function ResetINT1_TrapFLAG { //Push EAX to make sure whatever we do below doesn't affect code afterwards +EBP diff --git a/source2/Compiler/Cosmos.XSharp/AsmGenerator.cs b/source2/Compiler/Cosmos.XSharp/AsmGenerator.cs index 00f5b17c0..7f949e8bd 100644 --- a/source2/Compiler/Cosmos.XSharp/AsmGenerator.cs +++ b/source2/Compiler/Cosmos.XSharp/AsmGenerator.cs @@ -7,9 +7,9 @@ using System.IO; using XSharp.Nasm; namespace Cosmos.Compiler.XSharp { - /// This class performs the translation from X# source code into a target - /// assembly language. At current time the only supported assembler syntax is NASM. - /// + // This class performs the translation from X# source code into a target + // assembly language. At current time the only supported assembler syntax is NASM. + public class AsmGenerator { protected TokenPatterns mPatterns = new TokenPatterns(); @@ -20,11 +20,11 @@ namespace Cosmos.Compiler.XSharp { /// Invoke this method when end of source code file is reached to make sure the last /// function or interrupt handler has well balanced opening/closing curly braces. - private void AssertLastFunctionComplete() - { - if (!mPatterns.InFunctionBody) { return; } - throw new Exception( - "The last function or interrupt handler from source code file is missing a curly brace."); + private void AssertLastFunctionComplete() { + if (!mPatterns.InFunctionBody) { + return; + } + throw new Exception("The last function or interrupt handler from source code file is missing a curly brace."); } /// Parse the input X# source code file and generate the matching target assembly @@ -33,28 +33,25 @@ namespace Cosmos.Compiler.XSharp { /// The resulting target assembler content. The returned object contains /// a code and a data block. public Assembler Generate(string aSrcPathname) { - mPatterns.EmitUserComments = EmitUserComments; - mLineNo = 0; - var xResult = new Assembler(); - using (var xInput = new StreamReader(aSrcPathname)) - { - // Read one X# source code line at a time and process it. - while (true) - { - mLineNo++; - string xLine = xInput.ReadLine(); - if (xLine == null) - { - break; - } + mPatterns.EmitUserComments = EmitUserComments; + mLineNo = 0; + var xResult = new Assembler(); + using (var xInput = new StreamReader(aSrcPathname)) { + // Read one X# source code line at a time and process it. + while (true) { + mLineNo++; + string xLine = xInput.ReadLine(); + if (xLine == null) { + break; + } - var xAsm = ProcessLine(xLine, mLineNo); - xResult.Data.AddRange(xAsm.Data); - xResult.Code.AddRange(xAsm.Code); - } - } - AssertLastFunctionComplete(); - return xResult; + var xAsm = ProcessLine(xLine, mLineNo); + xResult.Data.AddRange(xAsm.Data); + xResult.Code.AddRange(xAsm.Code); + } + } + AssertLastFunctionComplete(); + return xResult; } /// Parse the input X# source code file and generate two new files with target @@ -81,8 +78,7 @@ namespace Cosmos.Compiler.XSharp { mPatterns.EmitUserComments = EmitUserComments; mLineNo = 0; // Read one X# source code line at a time and process it. - while (true) - { + while (true) { mLineNo++; string xLine = aInput.ReadLine(); if (xLine == null) { @@ -106,8 +102,7 @@ namespace Cosmos.Compiler.XSharp { /// Line number for debugging and diagnostic messages. /// The resulting target assembler content. The returned object contains /// a code and a data block. - protected Assembler ProcessLine(string aLine, int lineNumber) - { + protected Assembler ProcessLine(string aLine, int lineNumber) { Assembler xAsm; aLine = aLine.Trim();