public ScopeGuardStatement(TextPosition tp, ScopeGuardType type, ProgramContext block)
     : base(tp)
 {
     ScopeGuardType = type;
     Block = block;
     AppendChild(Block);
 }
示例#2
0
 protected EnumSymbol(TextPosition tp, string name, ProgramContext block)
     : base(tp)
 {
     Name = name;
     Block = block;
     AppendChild(Block);
 }
示例#3
0
 protected ClassSymbol(ClassType type)
 {
     ClassType = type;
     Block = new ProgramContext();
     AppendChild(Block);
     IsInitialize = true;
 }
示例#4
0
 public WithExpression(TextPosition cp, Element access, ProgramContext block)
 {
     Access = access;
     Block = block;
     AppendChild(Block);
     AppendChild(Access);
 }
示例#5
0
 public EnumSymbol(string name, ProgramContext block, IReadOnlyList<AttributeSymbol> attr, TypeSymbol bt)
 {
     Name = name;
     Block = block;
     _Attribute = attr;
     _BaseType = bt;
     AppendChild(Block);
 }
示例#6
0
 public CatchStatement(TextPosition tp, Element use, ProgramContext block)
     : base(tp)
 {
     Use = use;
     Block = block;
     AppendChild(Use);
     AppendChild(Block);
 }
示例#7
0
 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);
 }
示例#10
0
 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);
 }
示例#11
0
 public IfStatement(TextPosition tp, Element cond, ProgramContext then, ProgramContext els)
     : base(tp)
 {
     Condition = cond;
     Then = then;
     Else = els;
     AppendChild(Condition);
     AppendChild(Then);
     AppendChild(Else);
 }
示例#12
0
 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;
 }
示例#13
0
 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;
 }
示例#14
0
 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);
 }
示例#16
0
 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);
 }
示例#17
0
 private TypeSymbol BlockReturnType(ProgramContext block)
 {
     if(block == null)
     {
         return Root.Void;
     }
     if(block.IsInline)
     {
         return block[0].ReturnType;
     }
     else
     {
         return Root.Void; //todo ifブロックで値を返すための構文が必要。
     }
 }
示例#18
0
 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));
 }
示例#20
0
 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;
 }
示例#21
0
 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;
 }
示例#22
0
 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;
 }
示例#23
0
 public RequireStatement(TextPosition tp, ProgramContext block)
     : base(tp)
 {
     Block = block;
     AppendChild(Block);
 }
示例#24
0
 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)
 {
 }