public ScopeGuardStatement(TextPosition tp, ScopeGuardType type, ProgramContext block) : base(tp) { ScopeGuardType = type; Block = block; AppendChild(Block); }
protected EnumSymbol(TextPosition tp, string name, ProgramContext block) : base(tp) { Name = name; Block = block; AppendChild(Block); }
protected ClassSymbol(ClassType type) { ClassType = type; Block = new ProgramContext(); AppendChild(Block); IsInitialize = true; }
public WithExpression(TextPosition cp, Element access, ProgramContext block) { Access = access; Block = block; AppendChild(Block); AppendChild(Access); }
public EnumSymbol(string name, ProgramContext block, IReadOnlyList<AttributeSymbol> attr, TypeSymbol bt) { Name = name; Block = block; _Attribute = attr; _BaseType = bt; AppendChild(Block); }
public CatchStatement(TextPosition tp, Element use, ProgramContext block) : base(tp) { Use = use; Block = block; AppendChild(Use); AppendChild(Block); }
protected RoutineSymbol(RoutineType type, TokenType opType) { RoutineType = type; OperatorType = opType; Block = new ProgramContext(); AppendChild(Block); IsInitialize = true; }
public ModuleDeclaration(TextPosition tp, ProgramContext drcs, string name, string source, IReadOnlyList<Token> error) : base(tp) { Directives = drcs; Name = name; SourceText = source; ErrorToken = error; AppendChild(Directives); }
public ClassDeclaration(TextPosition tp, string name, ClassType type, TupleLiteral attr, TupleLiteral generic, TupleLiteral inherit, ProgramContext block) : base(tp, name, type, block) { AttributeAccess = attr; DecGenerics = generic; InheritAccess = inherit; AppendChild(AttributeAccess); AppendChild(DecGenerics); AppendChild(InheritAccess); }
public EnumDeclaration(TextPosition tp, string name, TupleLiteral attr, TupleLiteral generic, Element expli, ProgramContext block) : base(tp, name, block) { AttributeAccess = attr; DecGenerics = generic; ExplicitBaseType = expli; AppendChild(AttributeAccess); AppendChild(DecGenerics); AppendChild(ExplicitBaseType); }
public IfStatement(TextPosition tp, Element cond, ProgramContext then, ProgramContext els) : base(tp) { Condition = cond; Then = then; Else = els; AppendChild(Condition); AppendChild(Then); AppendChild(Else); }
protected RoutineSymbol(TextPosition tp, string name, RoutineType type, TokenType opType, ProgramContext block) : base(tp) { Name = name; RoutineType = type; OperatorType = opType; Block = block; AppendChild(Block); IsInitialize = true; }
protected ClassSymbol(TextPosition tp, string name, ClassType type, ProgramContext block) : base(tp) { Name = name; ClassType = type; Block = block; This = new ThisSymbol(this); Block.Append(This); AppendChild(Block); IsInitialize = true; }
public ForStatement(TextPosition tp, Element cond, Element of, Element at, ProgramContext block) : base(tp) { Condition = cond; Of = of; At = at; Block = block; AppendChild(Condition); AppendChild(Of); AppendChild(At); AppendChild(Block); }
public RoutineDeclaration(TextPosition tp, string name, RoutineType type, TokenType opType, TupleLiteral attr, TupleLiteral generic, TupleLiteral args, Element expli, ProgramContext block) : base(tp, name, type, opType, block) { AttributeAccess = attr; DecGenerics = generic; DecArguments = args; ExplicitType = expli; AppendChild(AttributeAccess); AppendChild(DecGenerics); AppendChild(DecArguments); AppendChild(ExplicitType); }
public LoopStatement(TextPosition tp, bool isLater, Element cond, Element use, Element by, ProgramContext block) : base(tp) { IsLater = isLater; Condition = cond; Use = use; By = by; Block = block; AppendChild(Condition); AppendChild(Use); AppendChild(By); AppendChild(Block); }
private TypeSymbol BlockReturnType(ProgramContext block) { if(block == null) { return Root.Void; } if(block.IsInline) { return block[0].ReturnType; } else { return Root.Void; //todo ifブロックで値を返すための構文が必要。 } }
public void Initialize(string name, RoutineType type, TokenType opType, IReadOnlyList<AttributeSymbol> attr, IReadOnlyList<GenericSymbol> gnr, IReadOnlyList<ArgumentSymbol> arg, TypeSymbol rt) { if (IsInitialize) { throw new InvalidOperationException(); } IsInitialize = true; Name = name; RoutineType = type; OperatorType = opType; Block = new ProgramContext(); _Attribute = attr; _Generics = gnr; _Arguments = arg; _CallReturnType = rt; AppendChild(Block); }
public void Transfer1() { var tc = Lexer.Lex("var a", string.Empty); var cp = new SlimChainParser(tc); var count = 0; var element = new ProgramContext(); ElementAction<Element> action = e => ++count; var ret = cp.Begin.Transfer(action, c => null, c => element).Transfer(action, c => element, c => null).End(tp => new TupleLiteral(tp, (Element)null)); Assert.That(ret, Is.Not.Null); Assert.That(count, Is.EqualTo(2)); }
public void Initialize(string name, ClassType type, ProgramContext block, IReadOnlyList<AttributeSymbol> attr, IReadOnlyList<GenericSymbol> gnr, IReadOnlyList<TypeSymbol> inherit) { if (IsInitialize) { throw new InvalidOperationException(); } IsInitialize = true; Name = name; ClassType = type; Block = block; This = new ThisSymbol(this); Block.Append(This); AppendChild(Block); _Attribute = attr; _Generics = gnr; _Inherit = inherit; }
private EnumSymbol ImportEnum(Type type) { var attribute = new List<AttributeSymbol>(); AppendEmbededAttribute(attribute, type); var ut = ImportType(type.GetEnumUnderlyingType()); var block = new ProgramContext(); var elem = new EnumSymbol(type.Name, block, attribute, ut); if (ImportDictionary.ContainsKey(type)) { return (EnumSymbol)ImportDictionary[type]; } ImportDictionary.Add(type, elem); foreach(var v in type.GetFields()) { if(!v.IsLiteral) { continue; } var f = new VariantSymbol(); ImportDictionary.Add(v, f); VariantType t; var a = new List<AttributeSymbol>(); AppendEmbededAttribute(a, v, out t); var dt = ImportType(v.FieldType); var def = new ValueSymbol(v.GetRawConstantValue()); f.Initialize(v.Name, t, a, dt, def); block.Append(f); } return elem; }
private ClassSymbol ImportPureType(Type type) { var elem = new ClassSymbol(); if (ImportDictionary.ContainsKey(type)) { return (ClassSymbol)ImportDictionary[type]; } ImportDictionary.Add(type, elem); ClassType classType; var attribute = new List<AttributeSymbol>(); AppendEmbededAttribute(attribute, type, out classType); var generic = CreateGenericList(type.GetGenericArguments()); var inherit = CreateInheritList(type); var block = new ProgramContext(); var ctor = type.GetConstructors(Binding); foreach (var c in ctor) { if(c.IsAssembly || c.IsFamilyAndAssembly || c.IsPrivate) { continue; } block.Append(ImportConstructor(c)); } //todo Eventのインポートに対応する。 //var eve = type.GetEvents(); //foreach (var e in eve) //{ // block.Append(ImportEvent(e)); //} var property = type.GetProperties(Binding); foreach (var p in property) { var name = p.GetIndexParameters().Count() > 0 ? RoutineSymbol.AliasCallIdentifier : p.Name; var g = p.GetMethod; if (g != null && !g.IsAssembly && !g.IsFamilyAndAssembly && !g.IsPrivate) { block.Append(ImportProperty(p.GetMethod, name)); } var s = p.SetMethod; if (s != null && !s.IsAssembly && !s.IsFamilyAndAssembly && !s.IsPrivate) { block.Append(ImportProperty(p.SetMethod, name)); } } var method = type.GetMethods(Binding); foreach (var m in method) { if (m.IsAssembly || m.IsFamilyAndAssembly || m.IsPrivate) { continue; } if(ImportDictionary.ContainsKey(m)) { continue; } block.Append(ImportMethod(m)); } var field = type.GetFields(Binding); foreach (var f in field) { if (f.IsAssembly || f.IsFamilyAndAssembly || f.IsPrivate) { continue; } block.Append(ImportField(f)); } var nested = type.GetNestedTypes(Binding); foreach (var n in nested) { if (n.IsNestedAssembly || n.IsNestedFamANDAssem || n.IsNestedPrivate) { continue; } block.Append(ImportType(n)); } elem.Initialize(TrimTypeNameMangling(type.Name), classType, block, attribute, generic, inherit); return elem; }
public RequireStatement(TextPosition tp, ProgramContext block) : base(tp) { Block = block; AppendChild(Block); }
public LambdaLiteral(TextPosition tp, string name, RoutineType type, TokenType op, TupleLiteral attr, TupleLiteral generic, TupleLiteral args, Element expli, ProgramContext block) : base(tp, name, type, op, attr, generic, args, expli, block) { }