├── Binaries ├── test-examples │ ├── empty.b │ ├── error.b │ ├── string-decl-crash.b │ ├── array-crash.b │ ├── break-b.b │ ├── test-label-crash.b │ ├── break-pre.b │ ├── test-register-assignment.b │ ├── offset-of-test.b │ ├── asm-blocks.b │ ├── struct-in-structs.b │ ├── error2.b │ ├── debug-pre │ ├── strip-test.b │ ├── array-init.b │ ├── memberaccess-ssa-test.b │ ├── test-logicalops.b │ ├── function-scope-test.b │ └── v-access.b ├── Emulator │ └── Emulator │ │ └── DefaultFont.dat ├── Running DCPUB Code.txt ├── techcompliant │ ├── cycle_test_against_admiral.b │ ├── base.b │ ├── helloworld.b │ ├── lps.b │ ├── test-sqrt.b │ ├── sqrt.b │ ├── random.b │ ├── lem.b │ ├── test-vec3.b │ ├── test-bitwise.b │ ├── test-number32.b │ ├── test-fixed.b │ ├── test-framework.b │ ├── hardware.b │ ├── std.b │ ├── itoa.b │ ├── blit.b │ ├── vec3.b │ ├── spacehack.b │ ├── vec.b │ ├── keyboard.b │ ├── fixed.b │ ├── number32.b │ ├── copy_disc.b │ └── bitwise-icm-cd2.txt ├── debug-pre ├── keyboard_demo.dc ├── peepholedef.txt └── vec3d.dc ├── b.zip ├── Irony ├── irony.snk ├── 010.Irony.2008.csproj.user ├── 010.Irony.2010.csproj.user ├── 100.IronySilverlight.2010.csproj.vspscc ├── Parsing │ ├── Parser │ │ ├── ParsingEventArgs.cs │ │ ├── SyntaxError.cs │ │ └── ParserStack.cs │ ├── Terminals │ │ ├── QuotedValueLiteral.cs │ │ ├── WikiTerminals │ │ │ ├── WikiBlockTerminal.cs │ │ │ ├── WikiTagTerminal.cs │ │ │ ├── _WikiTerminalBase.cs │ │ │ └── WikiTextTerminal.cs │ │ ├── FixedLengthLiteral.cs │ │ ├── CustomTerminal.cs │ │ ├── ImpliedSymbolTerminal.cs │ │ ├── NewLineTerminal.cs │ │ └── ConstantTerminal.cs │ ├── Data │ │ ├── ScannerData.cs │ │ ├── LanguageData.cs │ │ └── Construction │ │ │ └── LanguageDataBuilder.cs │ ├── Diagnostics │ │ ├── ParserTrace.cs │ │ └── ParserMessage.cs │ ├── AstInterfaces.cs │ ├── Grammar │ │ ├── LanguageAttribute.cs │ │ └── TermReportGroups.cs │ └── Scanner │ │ └── SourceLocation.cs ├── Interpreter │ ├── ValuesTable.cs │ ├── Ast │ │ ├── SpecialNodes │ │ │ ├── EmptyStatementNode.cs │ │ │ ├── NullNode.cs │ │ │ └── NotSupportedNode.cs │ │ ├── Base │ │ │ ├── AstException.cs │ │ │ └── AstInterfaces.cs │ │ ├── PrimitiveNodes │ │ │ ├── LiteralValueNode.cs │ │ │ └── IdentifierNode.cs │ │ ├── Statements │ │ │ ├── BlockNode.cs │ │ │ ├── IfNode.cs │ │ │ └── StatementListNode.cs │ │ ├── Expressions │ │ │ ├── ExpressionListNode.cs │ │ │ ├── BinaryOperationNode.cs │ │ │ └── UnaryOperationNode.cs │ │ └── Functions │ │ │ ├── ParamListNode.cs │ │ │ ├── FunctionCallNode.cs │ │ │ └── FunctionDefNode.cs │ ├── RuntimeException.cs │ ├── StackFrame.cs │ └── DataStack.cs ├── SilverlightOnly │ ├── Stopwatch.cs │ └── HashSet.cs └── 100.IronySilverlight.2010.csproj.user ├── Tools ├── Emulator │ ├── DefaultFont.dat │ ├── HardwareDevice.cs │ ├── LEM1802Window.cs │ ├── KeyboardWindow.cs │ └── Keyboard.cs └── DCPUBIDE │ ├── app.config │ ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ └── AssemblyInfo.cs │ ├── Program.cs │ └── TextBoxStream.cs ├── Irony.GrammarExplorer ├── Highlighter │ └── AboutCodeHighlighter.txt ├── 030.Irony.GrammarExplorer.2010.csproj.user ├── 030.Irony.GrammarExplorer.2010.csproj.vspscc ├── Properties │ ├── Settings.settings │ └── AssemblyInfo.cs ├── fmShowException.cs ├── app.config ├── Program.cs └── fmShowException.Designer.cs ├── DCPUB ├── Intermediate │ ├── Box.cs │ ├── LabelNode.cs │ ├── Label.cs │ ├── Peephole │ │ ├── Peepholes.cs │ │ ├── Matcher.cs │ │ ├── InstructionMatcher.cs │ │ ├── Rule.cs │ │ └── WholeInstructionMatcher.cs │ ├── Annotation.cs │ ├── Function.cs │ ├── StaticData.cs │ └── InlineStaticDataNode.cs ├── ConfigurationError.cs ├── EmissionStream.cs ├── Model │ ├── Label.cs │ ├── Struct.cs │ ├── Member.cs │ ├── Variable.cs │ └── Function.cs ├── Testing │ ├── HardwareDevice.cs │ └── TeleTerminalHardware.cs ├── Ast │ ├── AssignableNode.cs │ ├── NullStatementNode.cs │ ├── NotOperatorNode.cs │ ├── NegateOperatorNode.cs │ ├── IndexOperatorNode.cs │ ├── Assembly │ │ └── InstructionListAstNode.cs │ ├── GotoNode.cs │ ├── CastNode.cs │ ├── LabelNode.cs │ ├── ReturnStatementNode.cs │ ├── CompilableNode.cs │ ├── DereferenceNode.cs │ ├── BreakNode.cs │ ├── SizeofNode.cs │ ├── RootProgramNode.cs │ ├── OffsetOfNode.cs │ ├── ArrayInitializationNode.cs │ ├── Target.cs │ └── StringLiteralNode.cs ├── InternalError.cs ├── SSA │ ├── SSAValue.cs │ ├── SSAValue_Constant.cs │ ├── SSAValue_Variable.cs │ ├── SSAValue_DerefOffsetVirtual.cs │ ├── SSAValue_Virtual.cs │ └── SSAInstruction.cs ├── Upsert.cs ├── CompileOptions.cs ├── Properties │ └── AssemblyInfo.cs ├── Build.cs ├── OperandGrammar.cs ├── Preprocessor │ └── PreprocessedLineLocationTable.cs └── AssemblyGrammar.cs ├── .gitignore ├── DCPUBCL ├── FileEmissionStream.cs └── Properties │ └── AssemblyInfo.cs └── DCPUBPreprocessor ├── Program.cs └── Properties └── AssemblyInfo.cs /Binaries/test-examples/empty.b: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Binaries/test-examples/error.b: -------------------------------------------------------------------------------- 1 | #include error2.b 2 | -------------------------------------------------------------------------------- /b.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Blecki/DCPUB/HEAD/b.zip -------------------------------------------------------------------------------- /Irony/irony.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Blecki/DCPUB/HEAD/Irony/irony.snk -------------------------------------------------------------------------------- /Binaries/test-examples/string-decl-crash.b: -------------------------------------------------------------------------------- 1 | local message = "string literal"; 2 | -------------------------------------------------------------------------------- /Binaries/test-examples/array-crash.b: -------------------------------------------------------------------------------- 1 | static foo; 2 | local bar[2] = {&foo,&foo}; 3 | -------------------------------------------------------------------------------- /Binaries/test-examples/break-b.b: -------------------------------------------------------------------------------- 1 | This program exists merely to test the compiler's error reporting. 2 | -------------------------------------------------------------------------------- /Binaries/test-examples/test-label-crash.b: -------------------------------------------------------------------------------- 1 | 2 | goto ERROR; 3 | 4 | :ERROR 5 | 6 | goto ERROR; 7 | 8 | -------------------------------------------------------------------------------- /Tools/Emulator/DefaultFont.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Blecki/DCPUB/HEAD/Tools/Emulator/DefaultFont.dat -------------------------------------------------------------------------------- /Binaries/Emulator/Emulator/DefaultFont.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Blecki/DCPUB/HEAD/Binaries/Emulator/Emulator/DefaultFont.dat -------------------------------------------------------------------------------- /Binaries/test-examples/break-pre.b: -------------------------------------------------------------------------------- 1 | #define 2 | 3 | #define foo(a,b) whatever 4 | 5 | foo(a,b,c); 6 | 7 | #endif with extra stuff 8 | 9 | -------------------------------------------------------------------------------- /Binaries/Running DCPUB Code.txt: -------------------------------------------------------------------------------- 1 | TO compile: 2 | bin\b "your file" -b 3 | 4 | To test: 5 | lettuce\lettuce --nowait --little-endian "yourfile.bin" -------------------------------------------------------------------------------- /Binaries/test-examples/test-register-assignment.b: -------------------------------------------------------------------------------- 1 | local a = 5; 2 | local b = 20; 3 | 4 | local c = 0; 5 | c += a * b + 4 * a - b * a / b + a * b; 6 | 7 | -------------------------------------------------------------------------------- /Irony.GrammarExplorer/Highlighter/AboutCodeHighlighter.txt: -------------------------------------------------------------------------------- 1 | This highlighter is not a real thing, just a sketch - good enough to highlight samples in Grammar Explorer -------------------------------------------------------------------------------- /Binaries/test-examples/offset-of-test.b: -------------------------------------------------------------------------------- 1 | struct foo 2 | { 3 | bar; 4 | stool; 5 | } 6 | 7 | local x = offsetof stool in foo; 8 | local y = sizeof foo; 9 | 10 | -------------------------------------------------------------------------------- /Binaries/techcompliant/cycle_test_against_admiral.b: -------------------------------------------------------------------------------- 1 | #include default_environment.b 2 | 3 | local x = 0; 4 | while (x < 101) 5 | { 6 | printf("%N", x); 7 | x += 1; 8 | } 9 | -------------------------------------------------------------------------------- /Tools/DCPUBIDE/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Irony/010.Irony.2008.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | ShowAllFiles 4 | 5 | -------------------------------------------------------------------------------- /Binaries/test-examples/asm-blocks.b: -------------------------------------------------------------------------------- 1 | /* Test syntax of ASM blocks - All examples should be legal syntax. */ 2 | 3 | asm ( A = 4 ) {} 4 | asm ( A = 4; B = 5 ) {} 5 | asm ( A = 4, B = 5 ) {} 6 | asm () {} 7 | asm {} 8 | 9 | -------------------------------------------------------------------------------- /Binaries/test-examples/struct-in-structs.b: -------------------------------------------------------------------------------- 1 | struct foo 2 | { 3 | a; 4 | b; 5 | } 6 | 7 | struct bar 8 | { 9 | a:foo[sizeof foo]; 10 | b:foo[sizeof foo]; 11 | c; 12 | } 13 | 14 | local x = sizeof bar; 15 | -------------------------------------------------------------------------------- /Binaries/debug-pre: -------------------------------------------------------------------------------- 1 | /* 0 */ 2 | /* 1 */ 3 | /* 2 */ 4 | /* 3 */// This file has an error - and is included in another file! 5 | /* 4 */function foo(a, b) 6 | /* 5 */{ 7 | /* 6 */ c = 5; 8 | /* 7 */} 9 | /* 8 */ 10 | 11 | -------------------------------------------------------------------------------- /Binaries/test-examples/error2.b: -------------------------------------------------------------------------------- 1 | /* 0 */ 2 | /* 1 */ 3 | /* 2 */ 4 | /* 3 */// This file has an error - and is included in another file! 5 | /* 4 */function foo(a, b) 6 | /* 5 */{ 7 | /* 6 */ c = 5; 8 | /* 7 */} 9 | /* 8 */ 10 | -------------------------------------------------------------------------------- /Binaries/test-examples/debug-pre: -------------------------------------------------------------------------------- 1 | /* 0 */ 2 | /* 1 */ 3 | /* 2 */ 4 | /* 3 */// This file has an error - and is included in another file! 5 | /* 4 */function foo(a, b) 6 | /* 5 */{ 7 | /* 6 */ c = 5; 8 | /* 7 */} 9 | /* 8 */ 10 | 11 | -------------------------------------------------------------------------------- /DCPUB/Intermediate/Box.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Intermediate 7 | { 8 | public class Box where T : struct { public T data; } 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | bin 3 | obj 4 | 5 | # mstest test results 6 | TestResults 7 | *.suo 8 | *.lnk 9 | *.user 10 | *.bin 11 | *.dasm 12 | *.bat 13 | *.img 14 | *.pdc 15 | *.dll 16 | *.exe 17 | -------------------------------------------------------------------------------- /Irony/010.Irony.2010.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ShowAllFiles 5 | 6 | -------------------------------------------------------------------------------- /Binaries/test-examples/strip-test.b: -------------------------------------------------------------------------------- 1 | function a() {} 2 | function b() { c(); } 3 | function c() {} 4 | function d() { e(); } 5 | function e() { local a = &f; } 6 | function f() { } 7 | function g() { h(); } 8 | function h() { g(); } 9 | 10 | 11 | c(); 12 | d(); 13 | 14 | 15 | -------------------------------------------------------------------------------- /Binaries/test-examples/array-init.b: -------------------------------------------------------------------------------- 1 | static a; 2 | static b[2] = { 0xDEAD, 0xBEEF }; 3 | static c = &a; 4 | static d[2] = { &a, b }; 5 | function e() {} 6 | static f = &e; 7 | static g = "abcdef"; 8 | static h[3] = { d, &e, &a }; 9 | local i[2] = { 1, 2 }; 10 | local j[1] = { 3 }; 11 | 12 | -------------------------------------------------------------------------------- /Irony.GrammarExplorer/030.Irony.GrammarExplorer.2010.csproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ShowAllFiles 5 | 6 | -------------------------------------------------------------------------------- /Tools/DCPUBIDE/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DCPUB/ConfigurationError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB 7 | { 8 | public class ConfigurationError : Exception 9 | { 10 | public ConfigurationError(String msg) : base(msg) { } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DCPUB/EmissionStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB 7 | { 8 | public class EmissionStream 9 | { 10 | public int indentDepth = 0; 11 | 12 | public virtual void WriteLine(String line) { } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Irony/100.IronySilverlight.2010.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /DCPUB/Model/Label.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Interpreter.Ast; 6 | 7 | namespace DCPUB.Model 8 | { 9 | public class Label 10 | { 11 | public String declaredName; 12 | public Intermediate.Label realName; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DCPUB/Testing/HardwareDevice.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace DCPUB.Testing 3 | { 4 | public interface HardwareDevice 5 | { 6 | uint ManufacturerID { get; } 7 | uint HardwareID { get; } 8 | ushort Version { get; } 9 | 10 | void OnAttached(Emulator emu); 11 | void OnInterrupt(Emulator emu); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Tools/Emulator/HardwareDevice.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace DCPUB.Emulator 3 | { 4 | public interface HardwareDevice 5 | { 6 | uint ManufacturerID { get; } 7 | uint HardwareID { get; } 8 | ushort Version { get; } 9 | 10 | void OnAttached(Emulator emu); 11 | void OnInterrupt(Emulator emu); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Irony.GrammarExplorer/030.Irony.GrammarExplorer.2010.csproj.vspscc: -------------------------------------------------------------------------------- 1 | "" 2 | { 3 | "FILE_VERSION" = "9237" 4 | "ENLISTMENT_CHOICE" = "NEVER" 5 | "PROJECT_FILE_RELATIVE_PATH" = "" 6 | "NUMBER_OF_EXCLUDED_FILES" = "0" 7 | "ORIGINAL_PROJECT_FILE_PATH" = "" 8 | "NUMBER_OF_NESTED_PROJECTS" = "0" 9 | "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" 10 | } 11 | -------------------------------------------------------------------------------- /Binaries/test-examples/memberaccess-ssa-test.b: -------------------------------------------------------------------------------- 1 | // Do not run this code. 2 | 3 | struct foo 4 | { 5 | a; 6 | b; 7 | } 8 | 9 | local x:foo[sizeof foo]; 10 | 11 | x.a = 4; 12 | x.b = 5; 13 | 14 | if (x.a > x.b) 15 | { 16 | x.a = 6; 17 | } 18 | 19 | local y:foo = 0x2000; // Don't do this. 20 | 21 | if (y.a != y.b) 22 | { 23 | y.b = x.a; 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /DCPUB/Ast/AssignableNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Ast 7 | { 8 | public interface AssignableNode 9 | { 10 | Intermediate.IRNode EmitAssignment(CompileContext context, Model.Scope scope, Intermediate.Operand from, Intermediate.Instructions opcode); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Irony/Parsing/Parser/ParsingEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Irony.Parsing { 7 | public class ParsingEventArgs : EventArgs { 8 | public readonly ParsingContext Context; 9 | public ParsingEventArgs(ParsingContext context) { 10 | Context = context; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DCPUB/InternalError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB 7 | { 8 | public class InternalError : Exception 9 | { 10 | public InternalError(String msg) : base(msg) { } 11 | public InternalError(Exception InnerException) : base("Internal Error", InnerException) { } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Irony/Interpreter/ValuesTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Parsing; 6 | 7 | namespace Irony.Interpreter { 8 | public class ValuesTable : Dictionary { 9 | public ValuesTable(int capacity) : base(capacity) { } 10 | }//class 11 | 12 | public class ValuesList : List { } 13 | } 14 | -------------------------------------------------------------------------------- /DCPUB/SSA/SSAValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DCPUB.Intermediate; 6 | 7 | namespace DCPUB.SSA 8 | { 9 | public class SSAValue 10 | { 11 | public override string ToString() 12 | { 13 | throw new InternalError("Generic SSAValue should not exist in tree."); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DCPUB/Model/Struct.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Interpreter.Ast; 6 | 7 | namespace DCPUB.Model 8 | { 9 | public class Struct 10 | { 11 | public String name; 12 | public List members = new List(); 13 | public Ast.StructDeclarationNode Node; 14 | public int size; 15 | } 16 | } -------------------------------------------------------------------------------- /Irony/Interpreter/Ast/SpecialNodes/EmptyStatementNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Parsing; 6 | using Irony.Interpreter; 7 | 8 | namespace Irony.Interpreter.Ast { 9 | //A statement that does nothing, like "pass" command in Python. 10 | public class EmptyStatementNode : AstNode { 11 | 12 | 13 | }//class 14 | } 15 | -------------------------------------------------------------------------------- /Binaries/test-examples/test-logicalops.b: -------------------------------------------------------------------------------- 1 | //if (x > 3 && y < 4) {} 2 | 3 | local b = 5; 4 | if (b) {} 5 | 6 | local x = 5; 7 | local y = 9; 8 | local z = x && y; 9 | local i = 5 == 9; 10 | local j = x || y; 11 | local k = x && y || i; 12 | 13 | if (x && y) 14 | { 15 | // Test for short circuit. 16 | } 17 | 18 | if ((x > 0) && (y < 4)) 19 | { 20 | x = 3; 21 | } 22 | 23 | if (x > 0 && y < 4) 24 | { 25 | x = 5; 26 | } 27 | -------------------------------------------------------------------------------- /DCPUB/Upsert.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB 7 | { 8 | public static class HelperExtensions 9 | { 10 | public static void Upsert(this Dictionary Dict, A _a, B _b) 11 | { 12 | if (Dict.ContainsKey(_a)) Dict[_a] = _b; 13 | else Dict.Add(_a, _b); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DCPUB/Model/Member.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Interpreter.Ast; 6 | 7 | namespace DCPUB.Model 8 | { 9 | public class Member 10 | { 11 | public String name; 12 | public String typeSpecifier; 13 | public Struct referencedStruct; 14 | public int offset; 15 | public int size; 16 | public bool isArray; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Binaries/test-examples/function-scope-test.b: -------------------------------------------------------------------------------- 1 | function a() {} // Okay. 2 | 3 | function b() { // Okay. 4 | function c() { 5 | a(); 6 | 7 | local x = 5; 8 | local y = 5; 9 | 10 | if (x == y) 11 | { 12 | b(); 13 | c(); 14 | } 15 | } // ERROR: Functions must be at global scope 16 | 17 | local x = a() + c(); 18 | 19 | if (x == 0) 20 | { 21 | function d() {} 22 | } 23 | } 24 | 25 | a(); 26 | b(); 27 | //c(); // Error: Cannot find function 28 | 29 | -------------------------------------------------------------------------------- /Binaries/keyboard_demo.dc: -------------------------------------------------------------------------------- 1 | #include lem.dc 2 | #include keyboard.dc 3 | #include console.dc 4 | 5 | local lem = -1; 6 | local lem_vram[lem_vram_size]; 7 | 8 | lem = detect_lem(); 9 | initialize_lem(lem, lem_vram); 10 | 11 | local kb = find_keyboard(); 12 | 13 | local console[sizeof(console)]; 14 | console_make(console, lem_vram); 15 | 16 | console_stringout(console, "Hello world!"); 17 | 18 | while (true) 19 | { 20 | local key = kb_getkey(kb); 21 | if (key != 0) console_charout(console, key); 22 | } -------------------------------------------------------------------------------- /Binaries/techcompliant/base.b: -------------------------------------------------------------------------------- 1 | /* 2 | * _________.________________. __.___ ____________________ 3 | * \______ \ \__ ___/ \ / \ |/ _____/\_ _____/ 4 | * | | _/ | | | \ \/\/ / |\_____ \ | __)_ 5 | * | | \ | | | \ /| |/ \ | \ 6 | * |______ /___| |____| \__/\ / |___/_______ //_______ / 7 | * \/ \/ \/ \/ 8 | * 9 | * (c) BITWISE SCIENCES 1984 - 2108 10 | * 11 | */ 12 | 13 | 14 | -------------------------------------------------------------------------------- /Irony/SilverlightOnly/Stopwatch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Irony.Parsing.Construction { 4 | #if SILVERLIGHT 5 | //Less precise version for Silverlight 6 | internal class Stopwatch { 7 | long _startTime, _endTime; 8 | public void Start() { 9 | _startTime = Environment.TickCount; 10 | } 11 | public void Stop() { 12 | _endTime = Environment.TickCount; 13 | } 14 | public long ElapsedMilliseconds { 15 | get {return _endTime - _startTime; } 16 | } 17 | } 18 | #endif 19 | 20 | } 21 | -------------------------------------------------------------------------------- /DCPUB/SSA/SSAValue_Constant.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DCPUB.Intermediate; 6 | 7 | namespace DCPUB.SSA 8 | { 9 | public class SSAConstantValue : SSAValue 10 | { 11 | public ushort Value; 12 | 13 | public SSAConstantValue(ushort Value) 14 | { 15 | this.Value = Value; 16 | } 17 | 18 | public override string ToString() 19 | { 20 | return String.Format("{0:X4}", Value); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tools/DCPUBIDE/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace DCPUCIDE 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Application.Run(new Form1()); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DCPUB/SSA/SSAValue_Variable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DCPUB.Intermediate; 6 | 7 | namespace DCPUB.SSA 8 | { 9 | public class SSAVariableValue : SSAValue 10 | { 11 | public Operand AccessOperand; 12 | 13 | public SSAVariableValue(Operand AccessOperand) 14 | { 15 | this.AccessOperand = AccessOperand; 16 | } 17 | 18 | public override string ToString() 19 | { 20 | return "<" + AccessOperand.ToString() + ">"; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tools/DCPUBIDE/TextBoxStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | 7 | namespace DCPUCIDE 8 | { 9 | public class TextBoxStream : DCPUB.Assembly.EmissionStream 10 | { 11 | public RichTextBox textBox = null; 12 | 13 | public TextBoxStream(RichTextBox textBox) 14 | { 15 | this.textBox = textBox; 16 | } 17 | 18 | public override void WriteLine(string line) 19 | { 20 | textBox.AppendText(line + "\r\n"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Binaries/techcompliant/helloworld.b: -------------------------------------------------------------------------------- 1 | /* 2 | * _________.________________. __.___ ____________________ 3 | * \______ \ \__ ___/ \ / \ |/ _____/\_ _____/ 4 | * | | _/ | | | \ \/\/ / |\_____ \ | __)_ 5 | * | | \ | | | \ /| |/ \ | \ 6 | * |______ /___| |____| \__/\ / |___/_______ //_______ / 7 | * \/ \/ \/ \/ 8 | * 9 | * (c) BITWISE SCIENCES 1984 - 2108 10 | * 11 | */ 12 | 13 | #include default_environment.b 14 | 15 | clear(); 16 | printf("Hello world!"); 17 | -------------------------------------------------------------------------------- /DCPUBCL/FileEmissionStream.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUCCL 7 | { 8 | public class FileEmissionStream : DCPUB.EmissionStream 9 | { 10 | public System.IO.TextWriter stream = null; 11 | 12 | public FileEmissionStream(System.IO.TextWriter stream) 13 | { 14 | this.stream = stream; 15 | } 16 | 17 | public override void WriteLine(string line) 18 | { 19 | stream.WriteLine(new string(' ', indentDepth * 3) + line); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Binaries/techcompliant/lps.b: -------------------------------------------------------------------------------- 1 | /* 2 | * _________.________________. __.___ ____________________ 3 | * \______ \ \__ ___/ \ / \ |/ _____/\_ _____/ 4 | * | | _/ | | | \ \/\/ / |\_____ \ | __)_ 5 | * | | \ | | | \ /| |/ \ | \ 6 | * |______ /___| |____| \__/\ / |___/_______ //_______ / 7 | * \/ \/ \/ \/ 8 | * 9 | * (c) BITWISE SCIENCES 1984 - 2108 10 | * 11 | */ 12 | 13 | #ifndef _BITWISE_LIB_LPS_ 14 | #define _BITWISE_LIB_LPS_ 15 | 16 | #include number32.b 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /DCPUB/Ast/NullStatementNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Interpreter.Ast; 6 | 7 | namespace DCPUB.Ast 8 | { 9 | public class NullStatementNode : CompilableNode 10 | { 11 | public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode) 12 | { 13 | base.Init(context, treeNode); 14 | AsString = "NULL STATEMENT"; 15 | } 16 | 17 | public override Intermediate.IRNode Emit(CompileContext context, Model.Scope scope, Target target) 18 | { 19 | return new Intermediate.Annotation("Empty statement."); 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DCPUB/SSA/SSAValue_DerefOffsetVirtual.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DCPUB.Intermediate; 6 | 7 | namespace DCPUB.SSA 8 | { 9 | public class SSADereferenceOffsetVirtualValue : SSAValue 10 | { 11 | public SSAVirtualValue Virtual; 12 | public ushort Offset; 13 | 14 | public SSADereferenceOffsetVirtualValue(SSAVirtualValue Virtual, ushort Offset) 15 | { 16 | this.Virtual = Virtual; 17 | this.Offset = Offset; 18 | } 19 | 20 | public override string ToString() 21 | { 22 | return String.Format("[{0:X4}+VR{1}]", Offset, Virtual.VirtualIndex); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /DCPUB/CompileOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB 7 | { 8 | public class CompileOptions 9 | { 10 | public string @in = null; 11 | public string @out = null; 12 | public bool binary = false; 13 | public bool externals = false; 14 | public string peephole = null; 15 | public bool be = false; 16 | public bool preprocess = true; 17 | public bool emit_ir = false; 18 | public bool strip = false; 19 | public bool tidy = false; 20 | 21 | public bool collapse_statements = false; 22 | public bool ssa = false; 23 | 24 | public bool tidy_ir = false; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DCPUB/Testing/TeleTerminalHardware.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Testing 7 | { 8 | public class TeleTerminalHardware : HardwareDevice 9 | { 10 | public List Output = new List(); 11 | 12 | public uint ManufacturerID { get { return 0xDEADBEEF; } } 13 | public uint HardwareID { get { return 0xCAFE0000; } } 14 | public ushort Version { get { return 0xF005; } } 15 | 16 | public void OnAttached(Emulator emu) 17 | { 18 | 19 | } 20 | 21 | public void OnInterrupt(Emulator emu) 22 | { 23 | Output.Add(emu.registers[(int)Registers.B]); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Tools/Emulator/LEM1802Window.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace DCPUB.Emulator 11 | { 12 | public partial class LEM1802Window : Form 13 | { 14 | private LEM1802 lem = null; 15 | 16 | public LEM1802Window(LEM1802 lem) 17 | { 18 | this.lem = lem; 19 | InitializeComponent(); 20 | this.Show(); 21 | } 22 | 23 | private void LEM1802Window_Paint(object sender, PaintEventArgs e) 24 | { 25 | this.pictureBox1.Image = lem.ScreenImage; 26 | } 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Irony/Interpreter/Ast/SpecialNodes/NullNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Parsing; 6 | using Irony.Interpreter; 7 | 8 | namespace Irony.Interpreter.Ast { 9 | //A stub to use when AST node was not created (type not specified on NonTerminal, or error on creation) 10 | // The purpose of the stub is to throw a meaningful message when interpreter tries to evaluate null node. 11 | public class NullNode : AstNode { 12 | 13 | public NullNode(BnfTerm term) { 14 | this.Term = term; 15 | } 16 | 17 | public override void Evaluate(EvaluationContext context, AstMode mode) { 18 | context.ThrowError(Resources.ErrNullNodeEval, this.Term); 19 | } 20 | }//class 21 | } 22 | -------------------------------------------------------------------------------- /Binaries/peepholedef.txt: -------------------------------------------------------------------------------- 1 | // Peephole optimization definitions 2 | 3 | // Simple assign-back 4 | SET A, B / SET B, A => SET A, B; 5 | 6 | // Stack assign-back 7 | SET "PUSH", A / SET A, "PEEK" => SET "PUSH", A; 8 | 9 | // Preserve-pop 10 | SET "PUSH", A / ADD "SP", "0x0001" => ; 11 | 12 | // Register flip add 13 | SET B, A / SET A, "POP" / ADD A, B => ADD A, "POP"; 14 | 15 | // Push temp 16 | SET "J", A / SET "PUSH", "J" => SET "PUSH", A; 17 | 18 | //Addition with assign-back 19 | SET A, B / ADD A, "0x0001" / SET B, A => ADD B, "0x0001"; 20 | 21 | // B-Assign 22 | SET A, B / SET X, A => SET X, B; 23 | 24 | // Pointless stack cleanup 25 | ADD "SP", "0x0000" => ; 26 | 27 | //INCREMENT 28 | SET A, B / ADD C, A => ADD C, B; 29 | 30 | //The Zero add set 31 | SET A, "0x0000" / ADD A, B => SET A, B; 32 | -------------------------------------------------------------------------------- /DCPUB/Intermediate/LabelNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Intermediate 7 | { 8 | public class LabelNode : IRNode 9 | { 10 | public Label label; 11 | 12 | public override void Emit(EmissionStream stream) 13 | { 14 | stream.WriteLine(new String(' ', stream.indentDepth * 3) + ":" + label); 15 | } 16 | 17 | public override void EmitIR(EmissionStream stream, bool Tidy) 18 | { 19 | stream.WriteLine((Tidy ? "" : "[l /] ") + ":" + label); 20 | } 21 | 22 | public override void EmitBinary(List> binary) 23 | { 24 | label.position.data = (ushort)binary.Count; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Binaries/test-examples/v-access.b: -------------------------------------------------------------------------------- 1 | struct sample_struct 2 | { 3 | a; 4 | b; 5 | c; 6 | }; 7 | 8 | static ss1:sample_struct; 9 | 10 | static v1; 11 | 12 | local ss2:sample_struct; 13 | 14 | local v2; 15 | 16 | //sequential sets in one static struct: 17 | ss1.a = 1; 18 | ss1.b = 2; 19 | ss1.c = 3; 20 | //editing static struct values based on their previous values 21 | ss1.c = ss1.c + 1; 22 | 23 | //set on a static variable 24 | v1 = 1; 25 | //editing a static variable's value based on its previous value 26 | v1 = v1 + 1; 27 | 28 | //sequential sets in one local struct 29 | ss2.a = 1; 30 | ss2.b = 2; 31 | ss2.c = 3; 32 | //editing local struct values based on their previous values 33 | ss2.c = ss2.c + 1; 34 | 35 | //set on a local veriable 36 | v2 = 1; 37 | //editing a local variable based on its previous value 38 | v2 = v2 + 1; 39 | -------------------------------------------------------------------------------- /Binaries/techcompliant/test-sqrt.b: -------------------------------------------------------------------------------- 1 | /* 2 | * _________.________________. __.___ ____________________ 3 | * \______ \ \__ ___/ \ / \ |/ _____/\_ _____/ 4 | * | | _/ | | | \ \/\/ / |\_____ \ | __)_ 5 | * | | \ | | | \ /| |/ \ | \ 6 | * |______ /___| |____| \__/\ / |___/_______ //_______ / 7 | * \/ \/ \/ \/ 8 | * 9 | * (c) BITWISE SCIENCES 1984 - 2108 10 | * 11 | */ 12 | 13 | #include default_environment.b 14 | #include sqrt.b 15 | 16 | clear(); 17 | printf("TESTING SQRT.\n"); 18 | 19 | printf("SQRT 25 = %\n", sqrt(25)); 20 | printf("SQRT 9 = %\n", sqrt(9)); 21 | printf("SQRT 16 = %\n", sqrt(16)); 22 | printf("SQRT 17 = %\n", sqrt(17)); 23 | printf("SQRT 81 = %\n", sqrt(81)); 24 | 25 | 26 | -------------------------------------------------------------------------------- /DCPUB/Ast/NotOperatorNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Ast 7 | { 8 | class NotOperatorNode : BinaryOperationNode 9 | { 10 | public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode) 11 | { 12 | SkipInit = true; 13 | base.Init(context, treeNode); 14 | AddChild("first", treeNode.ChildNodes[0]); 15 | ChildNodes.Add(new NumberLiteralNode { Value = 0xFFFF }); 16 | AsString = "^"; 17 | } 18 | 19 | public override void ResolveTypes(CompileContext context, Model.Scope enclosingScope) 20 | { 21 | base.ResolveTypes(context, enclosingScope); 22 | ResultType = "word"; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /DCPUB/Ast/NegateOperatorNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Ast 7 | { 8 | class NegateOperatorNode : BinaryOperationNode 9 | { 10 | public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode) 11 | { 12 | SkipInit = true; 13 | base.Init(context, treeNode); 14 | AddChild("first", treeNode.ChildNodes[1]); 15 | ChildNodes.Add(new NumberLiteralNode { Value = 0x8000 }); 16 | AsString = "^"; 17 | } 18 | 19 | public override void ResolveTypes(CompileContext context, Model.Scope enclosingScope) 20 | { 21 | base.ResolveTypes(context, enclosingScope); 22 | ResultType = "word"; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /DCPUB/Model/Variable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Model 7 | { 8 | public enum VariableType 9 | { 10 | Local, 11 | Static, 12 | Constant, 13 | ConstantLabel, 14 | External 15 | } 16 | 17 | public class Variable 18 | { 19 | public String name; 20 | public Scope scope; 21 | public int stackOffset; 22 | public Intermediate.Label staticLabel; 23 | public int constantValue; 24 | public string typeSpecifier = "word"; 25 | public bool addressTaken = false; 26 | public Struct structType = null; 27 | public VariableType type; 28 | public bool isArray = false; 29 | 30 | public Ast.CompilableNode assignedBy = null; 31 | } 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /DCPUB/SSA/SSAValue_Virtual.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DCPUB.Intermediate; 6 | 7 | namespace DCPUB.SSA 8 | { 9 | public class SSAVirtualValue : SSAValue 10 | { 11 | public ushort VirtualIndex; 12 | public ushort Version; 13 | 14 | public SSAVirtualValue(ushort VirtualIndex) 15 | { 16 | this.VirtualIndex = VirtualIndex; 17 | this.Version = 0; 18 | } 19 | 20 | public SSAVirtualValue NewVersion() 21 | { 22 | var r = new SSAVirtualValue(VirtualIndex); 23 | r.Version = (ushort)(Version + 1); 24 | return r; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return "VR" + VirtualIndex + "(" + Version + ")"; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DCPUB/Intermediate/Label.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Intermediate 7 | { 8 | public class Label 9 | { 10 | private static int labelCount = 0; 11 | 12 | public Box position = new Box { data = 0 }; 13 | public string rawLabel; 14 | 15 | public Label() 16 | { 17 | rawLabel = "L" + labelCount; 18 | ++labelCount; 19 | } 20 | 21 | public static Label Make(String suffix) 22 | { 23 | var l = new Label(); 24 | l.rawLabel += suffix; 25 | return l; 26 | } 27 | 28 | public Label(String rl) { rawLabel = rl; } 29 | 30 | public override string ToString() 31 | { 32 | return rawLabel; 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Binaries/techcompliant/sqrt.b: -------------------------------------------------------------------------------- 1 | /* 2 | * _________.________________. __.___ ____________________ 3 | * \______ \ \__ ___/ \ / \ |/ _____/\_ _____/ 4 | * | | _/ | | | \ \/\/ / |\_____ \ | __)_ 5 | * | | \ | | | \ /| |/ \ | \ 6 | * |______ /___| |____| \__/\ / |___/_______ //_______ / 7 | * \/ \/ \/ \/ 8 | * 9 | * (c) BITWISE SCIENCES 1984 - 2108 10 | * 11 | */ 12 | 13 | #ifndef _BITWISE_LIB_SQRT_ 14 | #define _BITWISE_LIB_SQRT_ 15 | 16 | function sqrt(n) 17 | { 18 | local r = 0; 19 | local b = 1 << 14; 20 | 21 | while (n < b) b >>= 2; 22 | 23 | while (b != 0) 24 | { 25 | if (n < r + b) r >>= 1; 26 | else 27 | { 28 | n -= r + b; 29 | r = (r >> 1) + b; 30 | } 31 | 32 | b >>= 2; 33 | } 34 | 35 | return r; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /DCPUB/Intermediate/Peephole/Peepholes.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace DCPUB.Intermediate.Peephole 7 | { 8 | public class Peepholes 9 | { 10 | public RuleSet root = null; 11 | public static Irony.Parsing.Parser operandParser = new Irony.Parsing.Parser(new OperandGrammar()); 12 | 13 | public Peepholes(string defFile) 14 | { 15 | var Parser = new Irony.Parsing.Parser(new Grammar()); 16 | var defs = System.IO.File.ReadAllText(defFile); 17 | var _root = Parser.Parse(defs); 18 | if (_root.HasErrors()) root = new RuleSet(); 19 | else root = _root.Root.AstNode as RuleSet; 20 | } 21 | 22 | public void ProcessAssembly(List assembly) 23 | { 24 | root.ProcessAssembly(assembly); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Irony/Interpreter/Ast/SpecialNodes/NotSupportedNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Parsing; 6 | using Irony.Interpreter; 7 | 8 | namespace Irony.Interpreter.Ast { 9 | //A substitute node to use on constructs that are not yet supported by language implementation. 10 | // The script would compile Ok but on attempt to evaluate the node would throw a runtime exception 11 | public class NotSupportedNode : AstNode { 12 | string Name; 13 | public override void Init(ParsingContext context, ParseTreeNode treeNode) { 14 | base.Init(context, treeNode); 15 | Name = treeNode.Term.ToString(); 16 | AsString = Name + " (not supported)"; 17 | } 18 | 19 | public override void EvaluateNode(EvaluationContext context, AstMode mode) { 20 | context.ThrowError(Resources.ErrConstructNotSupported, Name); 21 | } 22 | 23 | }//class 24 | } 25 | -------------------------------------------------------------------------------- /Binaries/techcompliant/random.b: -------------------------------------------------------------------------------- 1 | /* 2 | * _________.________________. __.___ ____________________ 3 | * \______ \ \__ ___/ \ / \ |/ _____/\_ _____/ 4 | * | | _/ | | | \ \/\/ / |\_____ \ | __)_ 5 | * | | \ | | | \ /| |/ \ | \ 6 | * |______ /___| |____| \__/\ / |___/_______ //_______ / 7 | * \/ \/ \/ \/ 8 | * 9 | * (c) BITWISE SCIENCES 1984 - 2108 10 | * 11 | */ 12 | 13 | #ifndef _BITWISE_RANDOM_ 14 | #define _BITWISE_RANDOM_ 15 | 16 | static random_seed_a = 0x5678; 17 | static random_seed_b = 0x1234; 18 | 19 | function random() 20 | { 21 | asm ( B = &random_seed_a, C = &random_seed_b ) 22 | { 23 | MUL [B], 0x660D; 24 | SET A, [B] 25 | MUL [C], 0x0019 26 | ADX A, [C] 27 | ADD [B], 1 28 | ADD A, EX 29 | SET [C], A 30 | } 31 | // Return A 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /DCPUB/SSA/SSAInstruction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using DCPUB.Intermediate; 6 | 7 | namespace DCPUB.SSA 8 | { 9 | public class SSAInstruction 10 | { 11 | public Instructions Instruction; 12 | public SSAValue[] Operands = new SSAValue[2]; 13 | 14 | public SSAInstruction(Instructions Instruction, SSAValue Op0, SSAValue Op1) 15 | { 16 | this.Instruction = Instruction; 17 | Operands[0] = Op0; 18 | Operands[1] = Op1; 19 | } 20 | 21 | public override string ToString() 22 | { 23 | var r = Instruction.ToString() + " "; 24 | if (Operands[0] != null) r += Operands[0].ToString(); 25 | else r += "NULL"; 26 | r += ", "; 27 | if (Operands[1] != null) r += Operands[1].ToString(); 28 | else r += "NULL"; 29 | return r; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DCPUB/Model/Function.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Irony.Interpreter.Ast; 6 | 7 | namespace DCPUB.Model 8 | { 9 | public class Function 10 | { 11 | public String name; 12 | public Ast.FunctionDeclarationNode Node; 13 | public Scope localScope; 14 | public Intermediate.Label label; 15 | public string LabelName; 16 | public int parameterCount = 0; 17 | public String returnType = "void"; 18 | public List