コード例 #1
0
ファイル: BranchStatementNode.cs プロジェクト: colinvh/DCPUC
 public static void CompileBlock(Assembly assembly, Scope scope, CompilableNode block)
 {
     var blockScope = BeginBlock(scope);
     assembly.Barrier();
     block.Compile(assembly, blockScope, Register.DISCARD);
     assembly.Barrier();
     EndBlock(assembly, blockScope);
 }
コード例 #2
0
ファイル: InlineASMNode.cs プロジェクト: colinvh/DCPUC
 public override void Compile(Assembly assembly, Scope scope, Register target)
 {
     var lines = AsString.Split(new String[2]{"\n", "\r"}, StringSplitOptions.RemoveEmptyEntries);
     assembly.Barrier();
     foreach (var str in lines)
         assembly.Add(str + " ;", "", "");
 }
コード例 #3
0
ファイル: BlockNode.cs プロジェクト: colinvh/DCPUC
 public override void Compile(Assembly assembly, Scope scope, Register target)
 {
     foreach (var child in ChildNodes)
     {
         assembly.Barrier();
         (child as CompilableNode).Compile(assembly, scope, Register.DISCARD);
     }
 }
コード例 #4
0
ファイル: LibraryFunctionNode.cs プロジェクト: colinvh/DCPUC
 public override void CompileFunction(Assembly assembly, Scope topscope)
 {
     //if (references == 0) return;
     foreach (var line in code)
     {
         assembly.Barrier();
         assembly.Add(line, "", "");
     }
 }
コード例 #5
0
 public virtual void CompileFunction(Assembly assembly, Scope topscope)
 {
     Scope lScope;
     if (localScope != null)
     {
         foreach (var variable in topscope.variables)
             if (variable.location == Register.STATIC)
                 localScope.variables.Add(variable);
         lScope = localScope.Push(new Scope());
         assembly.Add(":" + label, "", "");
     }
     else
         lScope = topscope;
     assembly.Barrier();
     if (localScope != null) lScope.stackDepth += 1; //account for return address
     (ChildNodes[0] as CompilableNode).Compile(assembly, lScope, Register.DISCARD);
     if (localScope != null) CompileReturn(assembly, lScope);
     else assembly.Add("BRK", "", "");
     assembly.Barrier();
     //Should leave the return value, if any, in A.
     foreach (var function in lScope.pendingFunctions)
         function.CompileFunction(assembly, topscope);
 }