コード例 #1
0
ファイル: IsExpression.cs プロジェクト: KevinKelley/katahdin
 public IsExpression(Source source, object obj,
     object type)
         : base(source)
 {
     this.obj = (Expression) obj;
     this.type = (Expression) type;
 }
コード例 #2
0
 public WhileStatement(Source source, object condition,
     object body)
         : base(source)
 {
     this.condition = (Expression) condition;
     this.body = (Statement) body;
 }
コード例 #3
0
 public EqualityExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
コード例 #4
0
 public MultiplyExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
コード例 #5
0
 public GreaterOrEqualExpression(Source source,
     object a, object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
コード例 #6
0
 public DivideExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
コード例 #7
0
ファイル: NewExpression.cs プロジェクト: KevinKelley/katahdin
 public NewExpression(Source source, object type,
     object parameters)
         : base(source)
 {
     this.type = (Expression) type;
     this.parameters = (List<object>) parameters;
 }
コード例 #8
0
 public SubtractExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
コード例 #9
0
 public MemberExpression(Source source, object obj,
     object member)
         : base(source)
 {
     this.obj = (Expression) obj;
     this.member = (Name) member;
 }
コード例 #10
0
 public CallExpression(Source source, object callable,
     object parameters)
         : base(source)
 {
     this.callable = (Expression) callable;
     this.parameters = (List<object>) parameters;
 }
コード例 #11
0
 public AssignExpression(Source source, object to,
     object from)
         : base(source)
 {
     this.from = (Expression) from;
     this.to = (Expression) to;
 }
コード例 #12
0
 public SetPrecedenceStatement(Source source, object a,
     object relation, object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.relation = (string) relation;
     this.b = (Expression) b;
 }
コード例 #13
0
ファイル: IfStatement.cs プロジェクト: KevinKelley/katahdin
 public IfStatement(Source source, object condition,
     object trueBody, object falseBody)
         : base(source)
 {
     this.condition = (Expression) condition;
     this.trueBody = (Statement) trueBody;
     this.falseBody = (Statement) falseBody;
 }
コード例 #14
0
ファイル: TryStatement.cs プロジェクト: KevinKelley/katahdin
 public TryStatement(Source source, object tryBody,
     object catchVariable, object catchBody)
         : base(source)
 {
     this.tryBody = (Statement) tryBody;
     this.catchVariable = (Expression) catchVariable;
     this.catchBody = (Statement) catchBody;
 }
コード例 #15
0
 public ClassStatement(Source source, object name, object baseType,
     object members)
         : base(source)
 {
     this.name = (Name) name;
     this.baseType = (Expression) baseType;
     this.members = (List<object>) members;
 }
コード例 #16
0
 public ThrowStatement(Source source, object exception)
     : base(source)
 {
     this.exception = (Expression) exception;
 }
コード例 #17
0
 public ReferencePatternExpression(Source source, object name)
     : base(source)
 {
     this.name = (Expression) name;
 }
コード例 #18
0
 public ExpressionStatement(Source source,
     object expression)
         : base(source)
 {
     this.expression = (Expression) expression;
 }
コード例 #19
0
ファイル: NotExpression.cs プロジェクト: KevinKelley/katahdin
 public NotExpression(Source source, object a)
     : base(source)
 {
     this.a = (Expression) a;
 }
コード例 #20
0
 public ParenExpression(Source source, object body)
     : base(source)
 {
     this.body = (Expression) body;
 }
コード例 #21
0
ファイル: Option.cs プロジェクト: KevinKelley/katahdin
 public Option(Source source, object optionKey, object optionValue)
     : base(source)
 {
     this.optionKey = (Name) optionKey;
     this.optionValue = (Expression) optionValue;
 }
コード例 #22
0
        public void Define(RuntimeState state)
        {
            AbstractPattern basePattern;
            
            Type baseType;

            if (this.baseType != null)
            {
                baseType = (Type) this.baseType.Get(state);
                basePattern = (AbstractPattern) Pattern.PatternForType(baseType);
            }
            else
            {
                baseType = typeof(RuntimeObject);
                basePattern = null;
            }

            ClassBuilder classBuilder = new ClassBuilder(
                state.Runtime.CompilerModule,
                state.Scope.GetModule(),
                name.name,
                baseType);

            // Go through members
            
            if (members != null)
            {
                foreach (object member in members)
                    ((Member) member).Build(state, classBuilder);
            }
            
            UserDefinedNode userDefined = null;;
            
            if (classBuilder.Pattern == null)
            {
                bool parseMethod = false;;
                
                foreach (Method method in classBuilder.Methods)
                    if (method.Name == "Parse")
                    {
                        parseMethod = true;
                        break;
                    }
                
                if (parseMethod)
                {
                    userDefined = new UserDefinedNode(Source,
                        null);
                    
                    classBuilder.Pattern = new ConcretePattern(Source,
                        name.name, userDefined);
                }
                else
                    classBuilder.Pattern = new AbstractPattern(Source,
                        classBuilder.TypeBuilder.Name);
            }

            // Create the class, which closes the pattern, and define the pattern

            Type type = classBuilder.CreateType();
            state.Runtime.Grammar.PatternDefined(classBuilder.Pattern);

            state.Scope.SetName(name.name, type);
            
            if (userDefined != null)
                userDefined.Type = type;

            // Add a concrete class as an alt to its abstract

            if (basePattern != null)
            {
                basePattern.AddAltPattern(classBuilder.Pattern);
                basePattern.Updated();
            }
        }