public override object GetResult() { if (Init == null) Init = new CodeBlock(new Instruction[] {}); if (Update == null) Update = new CodeBlock(new Instruction[] {}); return new DmlBulletFactory(name, Init, Update); }
public DmlSystem(CodeBlock globalCode, DmlTimeline timeline, Dictionary<string, DmlBulletFactory> bullets) { GlobalCode = globalCode; Timeline = timeline; GlobalVars = new Dictionary<string, DmlObject>(); foreach (var bulletClass in bullets) GlobalVars[bulletClass.Key] = new DmlObject(DmlType.BulletClass, bulletClass.Value); Bullets = new List<DmlBullet>(); }
protected override void ProcessNext() { // Check for an assignment statement. if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_ASSIGN)) { throw DmlSyntaxError.BadAssignmentNamespace(); } else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_INIT)) { if (Init != null) throw DmlSyntaxError.DuplicateNamespaceInBullet("Init"); SetExpecting(DmlTokens.LANGLE); Advance(exception: DmlSyntaxError.BlockMissingDelimiters("Init")); string[] tokens = GetNamespaceBlock(); BulletInitBuilder initBuilder = new BulletInitBuilder(tokens, currentLine); initBuilder.Parse(); var initBlock = (Instruction[])initBuilder.GetResult(); Init = new CodeBlock(initBlock); } else if (DmlTokens.IsMatch(CurrentToken, DmlTokens.KW_UPDATE)) { if (Update != null) throw DmlSyntaxError.DuplicateNamespaceInBullet("Update"); SetExpecting(DmlTokens.LANGLE); Advance(exception: DmlSyntaxError.BlockMissingDelimiters("Update")); string[] tokens = GetNamespaceBlock(); BulletUpdateBuilder updateBuilder = new BulletUpdateBuilder(tokens, currentLine); updateBuilder.Parse(); var updateBlock = (Instruction[])updateBuilder.GetResult(); Update = new CodeBlock(updateBlock); } else throw DmlSyntaxError.InvalidTokenForContext(CurrentToken, "bullet"); }
public DmlBulletFactory(string name, CodeBlock init, CodeBlock update) { Name = name; Init = init; Update = update; }
public void SetCode(CodeBlock code) { Code = code; }