本次大作业的编译目标是 r0 虚拟机 (r0vm) 的汇编 (s0)。其设计参考了 JVM、DotNet CLR 和上学期的 c0 虚拟机。
r0vm 是一个具有线性内存空间的栈式虚拟机。内存空间以 8 位(1 字节)为单位寻址,栈空间以 64 位(8 字节)为单位压栈弹栈。
Result: | |
type: string // maybe int from enum? | |
value: string // id | |
Trigger: | |
type: string | |
value: string | |
Reaction: | |
id: string |
public static Vector2Int GetConsoleSize(Text text) | |
{ | |
text.font.RequestCharactersInTexture(" ", text.fontSize, text.fontStyle); | |
text.font.GetCharacterInfo(' ', out CharacterInfo info, text.fontSize, text.fontStyle); | |
var scaleFactor = text.canvas.scaleFactor; | |
// Unity requires fonts to be pixel perfect whether the "pixel perfect" | |
// tick is ticked or not in the root canvas | |
float fontWidth = Mathf.Round(info.advance * scaleFactor) / scaleFactor; |
public static Vector2Int GetConsoleSize(Text text) | |
{ | |
text.font.RequestCharactersInTexture(" ", text.fontSize, text.fontStyle); | |
text.font.GetCharacterInfo(' ', out CharacterInfo info, text.fontSize, text.fontStyle); | |
var scaleFactor = text.canvas.scaleFactor; | |
float fontWidth = info.advance; | |
float fontHeight = text.fontSize * text.lineSpacing; |
EOL -> '\n' | '\r' | '\r\n' | |
Whitespace -> ' ' | '\t' | |
EscapedSequence -> | |
| '\\' [bfnrt\\] | |
| '\u' [0-9a-fA-F]{4} | |
QuotedStringElement -> | |
| [^\\"] |
// # Basic grammar elements | |
Identifier: [a-zA-Z] [_0-9a-zA-Z]* | _ [_0-9a-zA-Z]+ | |
DecimalInteger: "0" | [1-9] [0-9]+ | |
DecimalFractionalPart: "." [0-9]+ | |
DecimalExponentPart: [Ee] [+-]? [0-9]+ | |
HexadecimalNumber: "0x" [0-9a-fA-F]+ | |
IntegerLiteral: (DecimalInteger | HexadecimalNumber) | |
FloatLiteral: DecimalInteger DecimalFractionalPart DecimalExponentPart? | |
| DecimalInteger DecimalExponentPart |
#include <stdio.h> | |
int charrate[128] = {0}; | |
typedef struct _HuffmanNode { | |
int w, p, lc, rc; | |
} hfn; | |
typedef struct _HuffmanCode { | |
int l; | |
unsigned long long v; |
g,i,r,l=35,s=-20,f=10;e(s){write(1,&s,1);}main(){for(;s<21;s+=2){for( | |
g=20;g>-21;)i=s*s*s*g*g<<5,r=s*s+g*g-99,e(r*r*r+i<0?l:l-3),--g;e(f);}} |
using System; | |
using System.Threading; | |
using System.IO; | |
using System.Threading.Tasks; | |
using System.Text.Unicode; | |
using System.Text; | |
using SharpCompress.Readers; | |
using MicroKnights.IO.Streams; | |
class Program |